[英]Mapbox Android SDK Third Party Vector Tiles
I've been using Mapbox's Android SDK for a prototype and was wondering if anyone knows how to use a vector tile map that is not from Mapbox's servers. 我一直在使用Mapbox的Android SDK作为原型,并且想知道是否有人知道如何使用不是来自Mapbox服务器的矢量平铺地图。 For example, I want to load Mapzen or even OpenMapTiles vector tile maps using Mapbox's Android SDK without much difference versus loading Mapbox's default map styles.
例如,我想使用Mapbox的Android SDK加载Mapzen甚至OpenMapTiles矢量切片地图,而与加载Mapbox的默认地图样式没有太大区别。
You could do this using MapView#setStyleUrl
. 您可以使用
MapView#setStyleUrl
进行此操作。
First create mapzen.json
in your assets/
directory with this simple style (be sure to replace YOUR_MAPZEN_API_KEY
with your real key) https://mapzen.com/developers/sign_up 首先以这种简单的样式在您的
assets/
目录中创建mapzen.json
(确保将您的真实密钥替换为YOUR_MAPZEN_API_KEY
) https://mapzen.com/developers/sign_up
{
"version": 8,
"sources": {
"osm": {
"type": "vector",
"tiles": ["https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mvt?api_key=[YOUR_MAPZEN_API_KEY]"]
}
},
"layers": [{
"id": "background",
"type": "background",
"paint": {
"background-color": "#41afa5"
}
}, {
"id": "water",
"type": "fill",
"source": "osm",
"source-layer": "water",
"filter": ["==", "$type", "Polygon"],
"paint": {
"fill-color": "#3887be"
}
}]
}
Then set the custom style on your MapView
: 然后在您的
MapView
上设置自定义样式:
mapView.setStyleUrl("asset://mapzen.json");
And finally, load the map: 最后,加载地图:
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
//customize map
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.