mapbox/mapbox-gl-js

off('load') then on('load') does not work using setStyle

Open

#10,946 opened on 2021年8月19日

GitHub で見る
 (2 comments) (0 reactions) (0 assignees)JavaScript (10,532 stars) (2,203 forks)batch import
bug :lady_beetle:good first issue

説明

mapbox-gl-js version: v2.4.0

browser: Chrome Version 92.0.4515.159

Steps to Trigger Behavior

Reproduce steps

  1. add Map.on('load', func)
  2. add Map.off('load', func)
  3. add Map.on('load', func2)
  4. call Map.setStyle()

Link to Demonstration

https://jsfiddle.net/tsuzk/6o8m9nad

This should work because of this test

Expected Behavior

The Map.on('load', func2) should get called after Map.setStyle()

Actual Behavior

The Map.on('load', func2) does not get called after Map.setStyle()

Workaround

re-instantiate the map with a new stlye https://jsfiddle.net/tsuzk/6o8m9nad/1/

Other info

  • This occurs on v1.9.0 so it's not a new behavior in v2.

Priority

Low, since there is a proper workaround

コントリビューターガイド