Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Layers are removed after updating Map style #10697

Closed
Dhvl-Golakiya opened this issue Dec 13, 2017 · 1 comment
Closed

Layers are removed after updating Map style #10697

Dhvl-Golakiya opened this issue Dec 13, 2017 · 1 comment
Labels
Android Mapbox Maps SDK for Android iOS Mapbox Maps SDK for iOS runtime styling support

Comments

@Dhvl-Golakiya
Copy link

Hi,

I am using Mapbox with Fusetools. I am adding multiple layers on a map and they are displayed perfectly. But when I change map style, all previously added layers are removed.

Code for changing map style in iOS:

self.mapView.styleURL = [[NSURL alloc] initWithString:mapStyle];

And for Android:
mapboxMap.setStyleUrl(mapStyle);

Should changing map style affect all added layers? Should I need to add layer again?

@jmkiley
Copy link
Contributor

jmkiley commented Dec 13, 2017

Hi @Dhvl-Golakiya -

When you call addLayer or addSource, you are adding that source or layer to your map's current style, not to the map directly. Therefore, you need to add any styles and sources to your new style after that style has finished loading.

We are discussing allowing sources and layers to persist after a style change, but do not have a timeline for that feature. See #6180 for discussions about workarounds. Hope this helps!

@jmkiley jmkiley closed this as completed Dec 13, 2017
@kkaefer kkaefer added Android Mapbox Maps SDK for Android iOS Mapbox Maps SDK for iOS question labels Dec 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android iOS Mapbox Maps SDK for iOS runtime styling support
Projects
None yet
Development

No branches or pull requests

4 participants