-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map.loaded() gets confused when a GeoJSON layer is added #3950
Comments
I just encountered this issue with a GeoJSON source layer exactly as @averas describes. Edit. I was using mapboxgl 0.28.0. I just tried with 0.31.0 and the behavior is the same. |
Ah, I think I may have just hit this. In my situation, I was generating and adding a GeoJSON source, and waiting for a |
Also hitting this issue, the UPDATE: This turned out to be my fault I believe, I was registering the |
I tracked down the reason |
mapbox-gl-js 0.31.0:
Steps to Trigger Behavior
Map#loaded
always returnstrue
as the map settlesMap#loaded
sporadically returnsfalse
even after the map settlesThe behaviour above can be evaluated at: http://codepen.io/anon/pen/OWMwOX
Open the console and and click the "Loaded" button to get the state of
Map#loaded
. I have never been able to provoke a falseMap#loaded
without the GeoJSON source/layer, but after it is added ("Add GeoJSON Layer") it will after a couple of pans/zooms (sometimes up to 10-15)This behaviour currently affects plugins such as Draw which is dependent on this state to add its dependencies. I know there are upcoming changes to
Map#loaded
(#3941, #2792) and hopefully this can be adressed as part of that.I would also like to suggest that some work is invested in more clearly defining and documenting the state-transition model for Mapbox GL JS so that is becomes very clear which underlying phenomena that make the
Map
move between different states, which events it will emit when doing so, and which parts of the API that are available when the map is in different states. There is certainly a lot of work already done here, but since even adding and removing Draw is hard to do in a clean manner (mapbox/mapbox-gl-draw#572) I argue there is some room for improvement.The text was updated successfully, but these errors were encountered: