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

Do not clear native layers and sources when style is reloading #15513

Merged
merged 1 commit into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,6 @@ private void onLocationLayerStop() {
}

isLayerReady = false;
locationLayerController.hide();
staleStateManager.onStop();
if (compassEngine != null) {
updateCompassListenerState(false);
Expand Down Expand Up @@ -1289,6 +1288,7 @@ private void enableLocationComponent() {

private void disableLocationComponent() {
isEnabled = false;
locationLayerController.hide();
onLocationLayerStop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,12 @@ void clear() {
for (Layer layer : layers.values()) {
if (layer != null) {
layer.setDetached();
nativeMap.removeLayer(layer);
}
}

for (Source source : sources.values()) {
if (source != null) {
source.setDetached();
nativeMap.removeSource(source);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,22 +405,4 @@ class StyleTest {
Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
}
}

@Test
fun testClearRemovesSourcesFirst() {
val source1 = mockk<GeoJsonSource>(relaxed = true)
every { source1.id } returns "source1"
val layer1 = mockk<SymbolLayer>(relaxed = true)
every { layer1.id } returns "layer1"

val builder = Style.Builder().withLayer(layer1).withSource(source1)
mapboxMap.setStyle(builder)
mapboxMap.notifyStyleLoaded()
mapboxMap.setStyle(Style.MAPBOX_STREETS)

verifyOrder {
nativeMapView.removeLayer(layer1)
nativeMapView.removeSource(source1)
}
}
}