mapbox / mapbox/mapbox-gl-js

Support loading icons asynchronously on styleimagemissing

Open
#8,335 20 comments 10 reactions 1 assignee View on GitHub

@ansis is already working on this.

Since Oct 15, 2019.

api :memo: feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Update: Design proposals that close this issue are in https://github.com/mapbox/mapbox-gl-js/issues/9018.

mapbox-gl-js version: 1.0.0

browser: Chrome 75.0.3770.80

Steps to Trigger Behavior
  1. Load a map with a style containing a layer that has a missing icon-image
  2. Attach to the styleimagemissing event and load an image for the missing icon-image
Link to Demonstration

This codepen demonstrates the behaviour: https://codepen.io/anon/pen/OeLYqW

It does the following:

  • Loads the streets-v11 style JSON (via the API)
  • Appends a symbol layer to the style's layers. This new layer re-uses an existing source layer (composite -> roads) but the icon-image is set to an non-existent value
  • It also attaches to the 'styleimagemissing' event and loads up a valid image when it fires.
  • Once the map has loaded, it waits 1.5 seconds then outputs how many features have been rendered from the test layer.

When you reload the codepen (reload the entire browser tab) you should see the number of features rendered is basically random. The correct answer (which you can see by changing the code-pen and setting the 'icon-image' property to e.g. beer-11 which is an image from the sprite) is 21, but I saw results like 0, 4, 23,24,25 (not sure how there is more!)

Expected Behavior

Features should render properly at initial zoom and all other zooms

Actual Behavior

On initial load, the features with the missing icon render seemingly at random.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.