-
Notifications
You must be signed in to change notification settings - Fork 41
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
Changing map-style causes layers to disappear #248
Comments
Note that one "fix" i've found for is to add mapStyle as a key for MapboxMap for example:
|
It is a "known bug" of Mapbox, when the style of a map is changed, any custom layer needs to be readded to the map. See mapbox/mapbox-gl-js#10534 and mapbox/mapbox-gl-js#8326 and this paragraph in the documentation:
I had a quick look at how this could be addressed in the components directly, but it is not really simple as the Your workaround is the simplest for now. |
I wonder if it would be easier to get rid of the MapboxSource and MapboxLayer components completely and just feed that data MapboxMap via props. Then it would easier to redraw all sources layers when the map was changed. |
Here is an example of the problem (click "Change Style" button): https://codesandbox.io/p/sandbox/3hm8nm (it's using a test api key). The red route line will disappear. Along with this console warning:
One would expect that changing the map style would not affect anything except the map style. This seems to be a problem with the underlying behaviour of the mapbox API. However one would expect that the Vue component should be able to handle this occurrance. If one has to manually load the layers back onto the map every time the style is changed (using the map instance directly) then there is really no point to having the component at all.
The text was updated successfully, but these errors were encountered: