2015-02-17 45 views

回答

2

小叶具有一个L.GeoJSON层,你可以用它来在地图上覆盖GeoJSON的集合。您需要使用您所选择的最喜欢的XHR/AJAX库检索对象加载您的JSON文件和实例化的GeoJSON的层:

// Fetch the geojson file 
$.getJSON('data.geo.json', function (data) { 
    // Define the geojson layer and add it to the map 
    L.geoJson(data).addTo(map); 
}); 

就这么简单。这里有Plunker工作示例:http://plnkr.co/edit/0eP6zm?p=info

有上L.GeoJSON一个非常好的教程上的单张网站本身:http://leafletjs.com/examples/geojson.html和这里的API参考:http://leafletjs.com/reference.html#geojson