1111import com .mapbox .geojson .Point ;
1212import com .mapbox .mapboxsdk .geometry .LatLng ;
1313import com .mapbox .mapboxsdk .location .modes .RenderMode ;
14+ import com .mapbox .mapboxsdk .log .Logger ;
1415import com .mapbox .mapboxsdk .maps .Style ;
1516import com .mapbox .mapboxsdk .style .expressions .Expression ;
1617import com .mapbox .mapboxsdk .style .layers .Layer ;
5960import static com .mapbox .mapboxsdk .utils .ColorUtils .colorToRgbaString ;
6061
6162final class SymbolLocationLayerRenderer implements LocationLayerRenderer {
63+
64+ private static final String TAG = "mbgl-locationSymbol" ;
6265 private Style style ;
6366 private final LayerSourceProvider layerSourceProvider ;
6467
@@ -179,6 +182,11 @@ public void setAccuracyRadius(Float accuracy) {
179182
180183 @ Override
181184 public void styleScaling (Expression scaleExpression ) {
185+ if (!style .isFullyLoaded ()) {
186+ Logger .w (TAG , "Style is not fully loaded, not able to get layer!" );
187+ return ;
188+ }
189+
182190 for (String layerId : layerSet ) {
183191 Layer layer = style .getLayer (layerId );
184192 if (layer instanceof SymbolLayer ) {
@@ -244,6 +252,11 @@ private void updateForegroundBearing(float bearing) {
244252 }
245253
246254 private void setLayerVisibility (@ NonNull String layerId , boolean visible ) {
255+ if (!style .isFullyLoaded ()) {
256+ Logger .w (TAG , "Style is not fully loaded, not able to get layer!" );
257+ return ;
258+ }
259+
247260 Layer layer = style .getLayer (layerId );
248261 if (layer != null ) {
249262 String targetVisibility = visible ? VISIBLE : NONE ;
@@ -266,6 +279,11 @@ public void adjustPulsingCircleLayerVisibility(boolean visible) {
266279 */
267280 @ Override
268281 public void stylePulsingCircle (LocationComponentOptions options ) {
282+ if (!style .isFullyLoaded ()) {
283+ Logger .w (TAG , "Style is not fully loaded, not able to get layer!" );
284+ return ;
285+ }
286+
269287 if (style .getLayer (PULSING_CIRCLE_LAYER ) != null ) {
270288 setLayerVisibility (PULSING_CIRCLE_LAYER , true );
271289 style .getLayer (PULSING_CIRCLE_LAYER ).setProperties (
@@ -318,6 +336,11 @@ private void addLocationSource() {
318336 }
319337
320338 private void refreshSource () {
339+ if (!style .isFullyLoaded ()) {
340+ Logger .w (TAG , "Style is not fully loaded, not able to get source!" );
341+ return ;
342+ }
343+
321344 GeoJsonSource source = style .getSourceAs (LOCATION_SOURCE );
322345 if (source != null ) {
323346 locationSource .setGeoJson (locationFeature );
0 commit comments