将Shapes文件添加为Mapbox地图上的图层 [英] Adding a Shapes files as a Layer on Mapbox Map

查看:1225
本文介绍了将Shapes文件添加为Mapbox地图上的图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个shapes file,来自此处.我希望将其添加到地图上,类似于在网页上进行的操作.我不太确定如何进行.我想在Web上使用它,因此要使用JavaScript.

I have a shapes file from here. I wish to add it on a Map, similar to what is done on the web page. I am not quite sure how to proceed with it. I want to use it on Web and hence use JavaScript.

有人建议我在地图上将shapes file用作Layer.但是如何去做呢?有MapboxLeafletOSM的经验的人请指导.

Someone suggested me to use the shapes file as a Layer on the map. But how to go about it? Anyone experience with Mapbox, Leaflet or OSM please guide.

推荐答案

为了加载SHP文件并将其显示在Leaflet/Mapbox.js地图上,您需要几个Leaflet

In order to load a SHP file and display it on a Leaflet / Mapbox.js map, you have several Leaflet plugins that can make the task easy.

例如 leaflet.shapefile (

For example leaflet.shapefile (online demo where you can drop your zipped SHP and DBF files).

您提到的数据源还提供了KML格式,该格式可能更易于使用.

The data source that you mention also provides KML format, which may be easier to use.

对于KML,您可以使用例如传单-杂食:

For KML, you can use for example leaflet-omnivore:

Leaflet&的

通用格式解析器Mapbox.js

universal format parser for Leaflet & Mapbox.js

var map = L.mapbox.map('map', 'mapbox.streets')
    .setView([38, -102.0], 5);

omnivore.kml('a.kml').addTo(map);

包含Leaflet和Leaflet-omnivore的实时示例: https://plnkr.co/edit/KVXqBScBuIrAahg4VsGi?p =预览

Live example with Leaflet and leaflet-omnivore: https://plnkr.co/edit/KVXqBScBuIrAahg4VsGi?p=preview

这篇关于将Shapes文件添加为Mapbox地图上的图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆