如何在Mapbox 4.1中添加自己的图块 [英] How to add own tile in Mapbox 4.1
问题描述
我有一个图块来源作为url,并希望将它们添加到我的地图中. 我可以使用 Google Map 和 OSMDroid 来做到这一点,但是我不知道如何使用 Mapbox 来解决这个问题.
I have a source for tiles as an url and want to add these to my map. I am able to do this with Google Map and OSMDroid, but I do not know how to figure it out using Mapbox.
我的网址的格式为"http...mysource..x=..y=..z=.."
我已经看到了一种针对Web的解决方案,但是我找不到用于移动设备的这种方法.
I have seen a solution for web, but I do not find such an approach for mobile.
推荐答案
我假设您有一个切片服务器的URL,例如http://server/tiles/{z}/{x}/{y}.png
.如果是,请更新您的问题.
I assume you have a URL for a tile server such as http://server/tiles/{z}/{x}/{y}.png
If so, please update your question.
请参见以下Mapbox示例, https://www.mapbox. com/android-sdk/examples/custom-raster/添加自定义Mapbox样式.注意setStyleUrl
的参数.打开该json文件并进行检查.
Please see this Mapbox example, https://www.mapbox.com/android-sdk/examples/custom-raster/ to add in a custom Mapbox Style. Note the parameter for setStyleUrl
. Open up that json file and inspect it.
mapView.setStyleUrl("https://www.mapbox.com/android-sdk/files/mapbox-raster-v8.json");
然后您将需要创建两个JSON文件.参见此项目(适用于iOS,但JSON文件与Android,Web,和iOS.).
You will then need to create two JSON files. See this project (which is for iOS, but the JSON files are identical for Android, Web, and 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样式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"
}
]
}
这篇关于如何在Mapbox 4.1中添加自己的图块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!