我假设您有一个磁贴服务器的 URL,例如http://server/tiles/{z}/{x}/{y}.png
如果是这样,请更新您的问题。
请参阅这个 Mapbox 示例,https://www.mapbox.com/android-sdk/examples/custom-raster/ https://www.mapbox.com/android-sdk/examples/custom-raster/添加自定义 Mapbox 样式。请注意参数setStyleUrl
。打开该 json 文件并检查它。
mapView.setStyleUrl("https://www.mapbox.com/android-sdk/files/mapbox-raster-v8.json");
然后,您需要创建两个 JSON 文件。看到这个project https://github.com/roblabs/osm2vectortiles-ios(适用于 iOS,但 Android、Web 和 iOS 的 JSON 文件是相同的。)。
tile.json
sample
{
"name": "geography-class",
"version": "1.0.0",
"description": "",
"type": "overlay",
"format": "png",
"minzoom": 0,
"maxzoom": 8,
"bounds": [-117.30596604, 32.78617375, -117.21820077, 32.88817706],
"scale": "1",
"profile": "mercator",
"tiles": ["http://server/tiles/{z}/{x}/{y}.png"],
"tilejson": "2.0.0",
"scheme": "xyz"
}
Mapbox 样式 JSON,将其放入参数中setStyleUrl()
{
"version": 8,
"sources": {
"yourTileLayer": {
"url": "http://server/tiles/tile.json",
"type": "raster",
"tiles": [
"http://server/tiles/{z}/{x}/{y}.png"
],
"tileSize": 256
}
},
"layers": [
{
"id": "yourTileLayer",
"type": "raster",
"source": "yourTileLayer"
}
]
}