diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/SymbolLocationLayerRenderer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/SymbolLocationLayerRenderer.java index dae5069c9..eed7aa64a 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/SymbolLocationLayerRenderer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/SymbolLocationLayerRenderer.java @@ -343,7 +343,7 @@ private void refreshSource() { GeoJsonSource source = style.getSourceAs(LOCATION_SOURCE); if (source != null) { - locationSource.setGeoJson(locationFeature); + locationSource.setGeoJson(locationFeature.toJson()); } } diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java index 286d90e8f..b8c374648 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java @@ -256,6 +256,9 @@ public GeoJsonSource(String id, Geometry geometry, GeoJsonOptions options) { * Updates the GeoJson with a single feature. The update is performed asynchronously, * so the data won't be immediately visible or available to query when this method returns. * + * Note: This method is not thread-safe. The Feature is parsed on a worker thread, please make sure + * the Feature is immutable. + * * @param feature the GeoJSON {@link Feature} to set */ public void setGeoJson(Feature feature) { @@ -270,6 +273,9 @@ public void setGeoJson(Feature feature) { * Updates the GeoJson with a single geometry. The update is performed asynchronously, * so the data won't be immediately visible or available to query when this method returns. * + * Note: This method is not thread-safe. The Geometry is parsed on a worker thread, please make sure + * the Geometry is immutable. + * * @param geometry the GeoJSON {@link Geometry} to set */ public void setGeoJson(Geometry geometry) { @@ -284,6 +290,9 @@ public void setGeoJson(Geometry geometry) { * Updates the GeoJson. The update is performed asynchronously, * so the data won't be immediately visible or available to query when this method returns. * + * Note: This method is not thread-safe. The FeatureCollection is parsed on a worker thread, please make sure + * the FeatureCollection is immutable. + * * @param featureCollection the GeoJSON FeatureCollection */ public void setGeoJson(@Nullable FeatureCollection featureCollection) { diff --git a/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java b/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java index f95d6fdf5..6dd923228 100644 --- a/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java +++ b/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java @@ -536,6 +536,7 @@ public void onNewLatLngValue_locationFeatureIsUpdated() { LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class); LocationComponentOptions options = mock(LocationComponentOptions.class); Feature locationFeature = mock(Feature.class); + when(locationFeature.toJson()).thenReturn("expected_geojson_string"); LocationLayerController layer = new LocationLayerController( mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options, internalRenderModeChangedListener, internalIndicatorPositionChangedListener, false); @@ -543,7 +544,7 @@ public void onNewLatLngValue_locationFeatureIsUpdated() { getAnimationListener(ANIMATOR_LAYER_LATLNG, layer.getAnimationListeners()).onNewAnimationValue(new LatLng()); // wanted twice (once for initialization) - verify(locationSource, times(2)).setGeoJson(locationFeature); + verify(locationSource, times(2)).setGeoJson("expected_geojson_string"); verify(internalIndicatorPositionChangedListener).onIndicatorPositionChanged(any(Point.class)); }