mapbox/mapbox-gl-js

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

Open

#10.946 aberto em 19 de ago. de 2021

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (2.203 forks)batch import
bug :lady_beetle:good first issue

Métricas do repositório

Stars
 (10.532 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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

Guia do colaborador