[MapSnapshotter] withLayers/withLayerBelow cause crash with navigation map (invalid native peer)
bgervan opened this issue · 0 comments
bgervan commented
Hi,
I am using mapbox-navigation-android with mapsnapshotter. I would like to add the navigation layers, but it drops "invalid native peer"
Sample code:
mapSnapshotter = MapSnapshotter(
_navigationView.context, MapSnapshotter.Options(800, 400)
.withStyleBuilder(navigationMapboxMap.retrieveMap()?.style?.json?.let { navigationMapboxMap.retrieveMap()?.style?.getLayer("mapbox-location-bearing-layer")?.let { it1 ->
Style.Builder().withLayer(
it1
).fromJson(it)
} })
.withCameraPosition(navigationMapboxMap.retrieveMap()?.cameraPosition))
The crash:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.important.mobilepro.dev, PID: 14913
java.lang.IllegalStateException: invalid native peer
at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.nativeAddLayerAbove(Native Method)
at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.addLayerAbove(MapSnapshotter.java:515)
at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.onDidFinishLoadingStyle(MapSnapshotter.java:785)
at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.nativeInitialize(Native Method)
at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.<init>(MapSnapshotter.java:424)
at ...createSnapshot(MapComponent.kt:370)
I tried with withLayers etc, other layer id, all result the same.
Without the withLayer, the snapshot doesn't render the navigation layer, nor the car icon.
What does the invalid native peer mean?