2013-02-26 89 views
2

我想弄清楚如何將lon/lat座標上的GeoJSON列表加載到MapBox地圖中。我覺得我很接近,我似乎無法讓它實際工作。將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 }); 

回答

0

我有同樣的問題加載geojson到我的地圖箱地圖。 JS中的評論實際上指出了原因:存在跨域請求限制。

你可以檢查same origin policy,你會想在其他地方運行應用程序。