openlayers / openlayers/openlayers

Image layer + RasterSource is not always drawn properly

Open
#15,211 1 comment 0 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

An Image layer with a Raster source backed by multiple Static image sources fails to be drawn under certain circumstances.

To Reproduce

  1. Use this sandbox case: https://codesandbox.io/s/simple-forked-nnpfj3?file=/main.js:230-278
  2. Click on map to add a rectangular image source
  3. Pan map so that the first image is no longer in the viewport
  4. Click on map to add another rectangular image source
  5. No image appears on map
  6. Only after you zoom out so that both images fit the viewport, will the layer appear

The test case shows that the beforeoperations event is not fired on the raster source step 5.

Also note that the entire layer, raster source and all images are rebuilt after each clicks. The redraw issue seems to somehow be connected with the previous "versions" of the Image layer even though they have been removed from the map.

Expected behavior
Every time the map is clicked, a raster image should appear at the mouse cursor.

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 with the linked CodeSandbox at main.js lines 230-278 and reproduce the click, pan, and second-click sequence. Trace when the raster source is rebuilt and whether the beforeoperations event fires after the first image leaves the viewport. Done means each newly added image appears immediately without zooming out.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.