使用外部地图的Mapbox GL [英] Mapbox GL using external maps
问题描述
我想在我的Android应用程序中使用Mapbox GL.该服务即将发布,我对使用渲染器有一个棘手的问题.
I want to use Mapbox GL in my Android application. This service is going to be released soon and I have a tricky question about using the renderer.
我喜欢渲染器本身,但是我真的很想在应用程序中使用自己的地图数据(而不是Mapbox提供的付费数据).例如,我想自行解析OpenStreetMaps数据,以某种方式对其进行自定义,然后将其放入渲染器中以在应用程序中显示.
I like the renderer itself, but I really want to use my own maps data in the application (not the data, offered by Mapbox and which is paid). For instance, I want to parse OpenStreetMaps data on my own, customise it somehow and then put inside of a renderer to show it in my application.
现在的问题是:使用Mapbox GL时是否可以使用我自己的地图数据?还是只能与Mapbox数据一起使用?
And now the question: is it possible to use my own maps data while using Mapbox GL? Or it can be only used with Mapbox data?
在此先感谢您的帮助.也许您知道其他解决此问题的方法?事实是,我要有矢量切片,而不是光栅切片.并且该项目计划在以后为iOS开发.
Thank you in advance for any help. Maybe you know any other well-done solutions for this problem? The thing is, that I want to have vector tiles, not the raster ones. And this project is planned to be developed for iOS later..
推荐答案
您可以将MapBox开源SDK与自己的图块一起使用.适用于Android,iOS或Node.JS的Mapbox Native渲染器可以直接与MapBox.com平台外部托管的图块一起使用.
You can use MapBox open-source SDK with your own tiles. The Mapbox Native renderer for Android, iOS or Node.JS can be used directly with tiles hosted outside of MapBox.com platform.
请参阅示例移动应用程序"OSM2VectorTiles",它从自定义服务器或从嵌入式MBTiles本地加载矢量切片.
See the sample mobile app "OSM2VectorTiles" loading the vector tiles from a custom server or locally from a embedded MBTiles.
- Android: https://play.google.com/store/apps/details?id = com.klokantech.osm2vectortiles
- iOS: https://itunes.apple.com/us/app/osm2vectortiles/id1089255502
- Android: https://play.google.com/store/apps/details?id=com.klokantech.osm2vectortiles
- iOS: https://itunes.apple.com/us/app/osm2vectortiles/id1089255502
诀窍是将API中的style
属性指向您自己的JSON样式文件-该文件会从您自己的服务器请求矢量切片.一个例子:
参见 https://gist.github.com/klokan/3eee87899644f5d82b3946bf0cd1e176
The trick is to point the style
attribute in the API to your own JSON style file - which requests the vector tiles from your own server. An example:
See https://gist.github.com/klokan/3eee87899644f5d82b3946bf0cd1e176
请参见项目 http://www.openmaptiles.org/,您可以在此处下载准备使用的矢量由OpenStreetMap制成的图块-或查看该项目的文档,了解如何生成自己的自定义矢量图块.
See project http://www.openmaptiles.org/, where you can download ready to use vector tiles made from OpenStreetMap - or check the documentation of this project on how to generate your own customised vector tiles.
在 https://openmaptiles.org/docs/或 https://gis.stackexchange.com/questions/125037/self-hosting-mapbox-vector -tiles
您可能需要在某个地方托管资产(字形+精灵)和JSON样式本身-或将它们直接嵌入到您的移动应用中.
You may need to host somewhere the assets (font glyphs + sprites) and the JSON style itself - or embed these directly into your mobile app.
如果要在服务器上使用相同JSON样式光栅化矢量图块-用于与旧版Web客户端兼容的Web应用程序(Leaflet等),或者用于静态地图或具有相同外观的打印输出在移动应用地图上,您可以检查 https://github.com/klokantech/tileserver-gl
If you want to rasterize the vector tiles with the same JSON style on a server - for a web-application compatible with old web clients (Leaflet, ...) or for static maps or print output with the same look&feel as you mobile app maps, you can check https://github.com/klokantech/tileserver-gl
这篇关于使用外部地图的Mapbox GL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!