Change style with lines/symblos #485
-
Hi, I set multiple styles url, that's changing by some variable like satelliteMap (if true, it's showing satellite, if not, normal map) I've multiple lines and symbols on the ma that I'm adding on some user interaction My problem is, all lines and symbols are removed when I'm changing the style... Is it normal ? I have to re add all of my lines.. when changing map style ? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ForWarZz, Are you using geoJSON? If so, I believe that when adding geoJSON you are essentially adding to the existing style. A typical style has all sources (your data) at the top and your layers (How your source data should render on the map) array beneath. When switching style urls I presume your layers and sources get removed as they are not in the style JSON that you have just fetched from your new url. To resolve, before switching your style url, you would need to keep a record of all your added sources and layers and then on style switch, add them all back (as you mentioned "re add all of my lines"). So to answer your question, yes. I would say this is normal behaviour. Hope this helps. I'm still learning how it all works myself, so if you or anyone else has a better understanding of it, please let me know. |
Beta Was this translation helpful? Give feedback.
Hi @ForWarZz,
Are you using geoJSON?
If so, I believe that when adding geoJSON you are essentially adding to the existing style. A typical style has all sources (your data) at the top and your layers (How your source data should render on the map) array beneath.
When switching style urls I presume your layers and sources get removed as they are not in the style JSON that you have just fetched from your new url.
To resolve, before switching your style url, you would need to keep a record of all your added sources and layers and then on style switch, add them all back (as you mentioned "re add all of my lines").
So to answer your question, yes. I would say this is normal behaviour.
Hope thi…