我试图弄清楚如何将 lon/lat 坐标上的 GeoJSON 列表加载到MapBox地图中。我想我已经接近了,我似乎无法让它真正发挥作用。
我在这里设置了一个演示页面:http: //sandbox.charliehield.com/mapbox/
这是 GeoJSON 文件:
{
"type": "MultiPoint",
"coordinates": [
[
"-105.277803",
"40.006977"
],
[
"-93.304988",
"44.947198"
],
[
"151.206990",
"-33.867487"
]
]
}
HTML 很简单:
<div id="map"></div>
和 JS:
var map = mapbox.map('map');
map.addLayer(mapbox.layer().id('examples.map-zr0njcqy'));
map.ui.zoomer.add();
// example.geojson is a well-formed GeoJSON document. For this
// style, the file must be on the same domain name as the map,
// or loading will not work due to cross-domain request restrictions
var markers = mapbox.markers.layer().url('markers.geojson');
mapbox.markers.interaction(markers);
map.addLayer(markers);
// Zoom and center the map
map.zoom(2).center({ lat: 39.74739, lon: -105 });