Skip to content

LocationLayerPlugin applyStyle fatal exception #87

Closed

Description

@P-Zenker

Platform: Android
Mapbox SDK version: 5.1.2
'mapbox-android-plugin-locationlayer', version: '0.1.0'

Steps to trigger behavior

Create a custom style (my drawables are copys of yours but with another color):

<style name="CULocationLayer" parent="LocationLayer">
  <item name="backgroundDrawable">@drawable/cu_mapbox_user_stroke_icon</item>
  <item name="foregroundDrawable">@drawable/cu_mapbox_user_icon</item>
  <item name="bearingDrawable">@drawable/cu_mapbox_user_bearing_icon</item>
  <item name="navigationDrawable">@drawable/cu_mapbox_user_puck_icon</item>
  <item name="accuracyAlpha">0.15</item>
  <item name="accuracyColor">@color/mapbox_plugin_location_layer_blue</item>
</style>

If I use locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine, R.style.CULocationLayer); everything works fine.

But with locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine); locationLayerPlugin.applyStyle(R.style.CULocationLayer); a fatal exception occurs.

08-22 11:17:00.886 9736-9736/? E/AndroidRuntime: FATAL EXCEPTION: main
 Process: med.android.catchup.com.mapboxtest, PID: 9736
 com.mapbox.mapboxsdk.style.sources.CannotAddSourceException: Source mapbox-location-source already exists
  at com.mapbox.mapboxsdk.maps.NativeMapView.nativeAddSource(Native Method)
  at com.mapbox.mapboxsdk.maps.NativeMapView.addSource(NativeMapView.java:798)
  at com.mapbox.mapboxsdk.maps.MapboxMap.addSource(MapboxMap.java:419)
  at com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayer.addSources(LocationLayer.java:100)
  at com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayer.initialize(LocationLayer.java:47)
  at com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayer.<init>(LocationLayer.java:41)
  at com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin.applyStyle(LocationLayerPlugin.java:196)
  at med.android.catchup.com.mapboxtest.LocationLayerModesActivity.onMapReady(LocationLayerModesActivity.java:94)
  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onMapReady(MapView.java:945)
  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.access$1000(MapView.java:910)
  at com.mapbox.mapboxsdk.maps.MapView$MapCallback$1.run(MapView.java:928)
  at android.os.Handler.handleCallback(Handler.java:751)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:154)
  at android.app.ActivityThread.main(ActivityThread.java:6119)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Activity

  1. self-assigned this
    on Aug 23, 2017
  2. added
    bug
    location-layer-plugin
    on Aug 23, 2017
  3. tobrun commented on Dec 2, 2017

    @tobrun
    Member

    Will be fixed with #196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buglocation-layer-plugin

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions