I used the MapSnapshotter to capture the bitmap of the map. However, I could only get the image of the base map but not the polylines that I have drawn over it, which is the running route of the user and is crucial to my project. Is there anyway to capture the map image together with the polylines?
I used a LineManager to draw my polylines.
Code below:
startSnapShot(mapboxMap.getProjection().getVisibleRegion().latLngBounds,
mapView.getMeasuredHeight(),
mapView.getMeasuredWidth());
--------------
private void startSnapShot(LatLngBounds latLngBounds, int height, int width) {
mapboxMap.getStyle(style -> {
if (mapSnapshotter == null) {
// Initialize snapshotter with map dimensions and given bounds
MapSnapshotter.Options options =
new MapSnapshotter.Options(width, height)
.withCameraPosition(mapboxMap.getCameraPosition())
.withStyle(style.getUri())
.withRegion(latLngBounds);
mapSnapshotter = new MapSnapshotter(RunTracker.this, options);
} else {
// Reuse pre-existing MapSnapshotter instance
mapSnapshotter.setSize(width, height);
mapSnapshotter.setRegion(latLngBounds);
}
mapSnapshotter.start(snapshot -> passBitmap(snapshot.getBitmap()));
});
}