Mapbox-gl-native: Remove and add same name vector Source carsh

Created on 12 Jun 2017  路  5Comments  路  Source: mapbox/mapbox-gl-native

Platform:Android
Mapbox SDK version:5.1.0-beta.4

Steps to trigger behavior

1.map has already vector SourceIndoor
2.remove Source Indoor
3.add Vector Source Indoor

Expected behavior

replace Indoor Source

Actual behavior

App carsh,toastcom.mapbox.mapboxsdk.style.sources.CannotAddSourceException: Source indoor already exists

Android

Most helpful comment

The source is likely still in use by one or more layers, so it cannot be removed. Check the logs for "Source 'Indoor' is in use, cannot remove ". This behavior was added in 005dc6d122d5ae0c8d20d2f7297649d2bbae9ac8.

If you believe this is not the case, please provide sample code that replicates the issue.

All 5 comments

The source is likely still in use by one or more layers, so it cannot be removed. Check the logs for "Source 'Indoor' is in use, cannot remove ". This behavior was added in 005dc6d122d5ae0c8d20d2f7297649d2bbae9ac8.

If you believe this is not the case, please provide sample code that replicates the issue.

com.mapbox.mapboxsdk.style.sources.CannotAddSourceException: Source mapbox-android-symbol-source already exists

having the same trouble with the annotation plugin .
what is the best way to set a new style and keep all the symbols?
the exception is thrown when i set new manager with new style
this.symbolManager = new SymbolManager(this.mapView, this.mapboxMap, newMapStyle);

Happens with other managers too on 7.3.2:

private val lineManager = LineManager(mapView,mapboxMap, style)
private val circleManager = CircleManager(mapView, mapboxMap, style)
private val symbolManager = SymbolManager(mapView, mapboxMap, style)
private val fillManager = FillManager(mapView, mapboxMap, style)

What would be a proper way to remove the old source?

Happens with other managers too on 7.3.2:

private val lineManager = LineManager(mapView,mapboxMap, style)
private val circleManager = CircleManager(mapView, mapboxMap, style)
private val symbolManager = SymbolManager(mapView, mapboxMap, style)
private val fillManager = FillManager(mapView, mapboxMap, style)

What would be a proper way to remove the old source?

For me it worked only if I removed the selected-marker-layer first, then the marker-layer, then the selected-marker-source, then the marker-source. This way it didn't throw already in use error.

The source is likely still in use by one or more layers, so it cannot be removed. Check the logs for "Source 'Indoor' is in use, cannot remove ". This behavior was added in 005dc6d.

If you believe this is not the case, please provide sample code that replicates the issue.

"CannotAddSourceException: Source already exists"

Had a problem where I removed source, then removed Layer, and then added again source and layer with the same name, and it would trow an error that it cant create source with the same name.

The problem was that I had to delete layer before I delete the source.

Your comment helped me to realize this.

Was this page helpful?
0 / 5 - 0 ratings