diff --git a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/location/SymbolLocationLayerRenderer.java b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/location/SymbolLocationLayerRenderer.java index 2983e322a..ee193dddf 100644 --- a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/location/SymbolLocationLayerRenderer.java +++ b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/location/SymbolLocationLayerRenderer.java @@ -319,6 +319,11 @@ final class SymbolLocationLayerRenderer implements LocationLayerRenderer { } private void refreshSource() { + // prevents exception when other style has been set with an update in flight + // https://github.com/maplibre/maplibre-native/issues/3348 + if (!style.isFullyLoaded()) { + return; + } GeoJsonSource source = style.getSourceAs(LOCATION_SOURCE); if (source != null) { locationSource.setGeoJson(locationFeature); diff --git a/platform/android/MapLibreAndroid/src/test/java/org/maplibre/android/location/LocationLayerControllerTest.kt b/platform/android/MapLibreAndroid/src/test/java/org/maplibre/android/location/LocationLayerControllerTest.kt index 3deb34b28..fdd31bfaa 100644 --- a/platform/android/MapLibreAndroid/src/test/java/org/maplibre/android/location/LocationLayerControllerTest.kt +++ b/platform/android/MapLibreAndroid/src/test/java/org/maplibre/android/location/LocationLayerControllerTest.kt @@ -966,6 +966,7 @@ class LocationLayerControllerTest { val locationSource = Mockito.mock(GeoJsonSource::class.java) Mockito.`when`(style.getSourceAs(LocationComponentConstants.LOCATION_SOURCE)) .thenReturn(locationSource) + Mockito.`when`(style.isFullyLoaded).thenReturn(true) val sourceProvider = buildLayerProvider() Mockito.`when`( sourceProvider.generateSource(