openlayers / openlayers/openlayers

Error when getting attributions of a BingMaps layer

Open
#15,928 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
12.6k
Forks
3.2k
Avg merge
2d 17h
Merged PRs (30d)
21

Description

Describe the bug
I sometimes have an error when getting the attributions of a BingMaps layer:

TypeError: Cannot read properties of undefined (reading '1')
    at BingMaps.js:315:43
    at Array.map (<anonymous>)
    at BingMaps.js:308:35
    at TileLayer.getAttributions (Layer.js:352:24)

When debugging, the coverrageArea object doesn't have a bbox property:

{"zoomMin":1,"zoomMax":21,"jsonBoundingBox":[-90,-180,90,180],"boundingBox":{"northeast":{"type":"Point","coordinates":[90,180]},"southwest":{"type":"Point","coordinates":[-90,-180]},"southLatitude":-90,"westLongitude":-180,"northLatitude":90,"eastLongitude":180}}

To Reproduce
I don't know when this happens. It works correctly most of the time...

Steps to reproduce the behavior:

  1. Add a BingMaps layer
  2. In a 'postrender' event, call getAttributions on the BingMaps layer

Expected behavior
No error in the console

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in BingMaps.js around lines 308-315, then inspect Layer.js around getAttributions. Reproduce with a BingMaps layer and a postrender handler calling getAttributions, especially when coverageArea has boundingBox but no bbox. Done means attribution lookup completes without a console error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.