我有一个作为 url 的图 block 源,想将它们添加到我的 map 中。 我可以使用 Google Map 和 OSMDroid 来做到这一点,但我不知道如何使用 Mapbox 来解决这个问题。
我的网址格式为 "http...mysource..x=..y=..z=.."
我已经看到了针对网络的解决方案,但我没有找到针对移动设备的这种方法。
最佳答案
我假设您有一个 tile 服务器的 URL,例如 http://server/tiles/{z}/{x}/{y}.png
如果是这样,请更新您的问题.
请参阅此 Mapbox 示例,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 (适用于 iOS,但 JSON 文件对于 Android、Web 和 iOS 是相同的。)。
tile.json
示例
{
"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 Style 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"
}
]
}
关于android - 如何在 Mapbox 4.1 中添加自己的图 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40411025/