mapbox/mapbox-gl-js

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

Open

#10,946 建立於 2021年8月19日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)JavaScript (10,532 star) (2,203 fork)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

貢獻者指南