I have been trying to find an efficient way to show multiple views of a mapbox map, and I have landed on the mapbox snapshotter. However I have had little luck when trying to add a geojson string of coordinates to the snapshot.
I used the below code:
int width = myContext.getResources().getDisplayMetrics().widthPixels;
int height = (int) convertDpToPixel(200f, myContext);
MapSnapshotter.Options snapShopOptions = new MapSnapshotter.Options(width, height);
LatLngBounds bounds = new LatLngBounds.Builder()
.include(post.getPath().get(0))
.include(post.getPath().get(post.getPath().size() - 1))
.build();
snapShopOptions.withRegion(bounds);
snapShopOptions.withStyle(myContext.getString(R.string.outdoor_style));
mapSnapshotter = new MapSnapshotter(myContext, snapShopOptions);
mapSnapshotter.setStyleJson(String.valueOf(new Style.Builder()
.fromUri("mapbox://styles/mapbox/outdoors-v11")));
mapSnapshotter.start(new MapSnapshotter.SnapshotReadyCallback() {
@Override
public void onSnapshotReady(MapSnapshot snapshot) {
Bitmap bitmapImage = snapshot.getBitmap();
Glide.with(myContext).load(bitmapImage).into(holder.mapSnapShot);
}
});
I have tried initializing a MapboxMap object and adding the geojson to that feature and then using the .getProjection(), but it still does not show the route.
Can anyone help me solve this issue??