-
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
Changing map style remove its data #2144
Comments
How are you adding the data to the map - by addSource and addLayer? If so, those API calls are adding properties to the style. So, setting the style replaces it, including the things you added: there is no concept of overlay or 'added data' in mapbox gl js, it is all one map. |
Yes I'm using |
Do you have an idea of how this could be clarified? I think our docs are pretty explicit about the actual behavior of the library, and the expectation that setStyle won't affect a modified style (or that addSource modifies something other than the style) is a misapplied assumption from other mapping libraries. |
Yeah Mapbox docs are pretty clear indeed, but despite having spent some hours reading it again and again, this behavior looked like a bug to me :) So I think what you just explained could be added here in the docs: https://www.mapbox.com/mapbox-gl-js/api/#Map.setStyle
|
I don't think that this is a good addition to documentation. The same is true of setFilter calls, and everything else that explicitly says that it changes styles in the documentation. While it's unfortunate that this cost you some time, our documentation only has space to say what the behavior is, not the many things it isn't. |
When programmatically changing a map style with
map.setStyle()
, all its datas are removed. Example in video: http://streamable.com/3i0wIt's not documented but I guess it's not the supposed behavior.
The text was updated successfully, but these errors were encountered: