我想将 GeoJson 添加到 mapbox mapsnapshot
I want to add GeoJson to mapbox mapsnapshot
我一直在努力寻找一种有效的方式来显示 mapbox 地图的多个视图,并且我找到了 mapbox 快照器。但是,我在尝试向快照添加 geojson 坐标字符串 时运气不佳。
我使用了下面的代码:
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);
}
});
我已经尝试初始化 MapboxMap 对象并将 geojson 添加到该要素,然后使用 .getProjection(),但它仍然没有显示路线。
谁能帮我解决这个问题??
我最终联系了 Mapbox 支持,但目前该功能不受支持。他们的确切报价是 "Mapbox's MapSnapshotter does not support your use case, but it will once runtime styling is supported by the snapshotter."
支持然后将我指向此 post Android Convert current screen to bitmap。
希望如果有人和我一样挣扎,这将有助于节省一些时间!
我一直在努力寻找一种有效的方式来显示 mapbox 地图的多个视图,并且我找到了 mapbox 快照器。但是,我在尝试向快照添加 geojson 坐标字符串 时运气不佳。
我使用了下面的代码:
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);
}
});
我已经尝试初始化 MapboxMap 对象并将 geojson 添加到该要素,然后使用 .getProjection(),但它仍然没有显示路线。
谁能帮我解决这个问题??
我最终联系了 Mapbox 支持,但目前该功能不受支持。他们的确切报价是 "Mapbox's MapSnapshotter does not support your use case, but it will once runtime styling is supported by the snapshotter."
支持然后将我指向此 post Android Convert current screen to bitmap。
希望如果有人和我一样挣扎,这将有助于节省一些时间!