我遇到了一個任務,它需要使用leaflet js庫和geojson作爲數據存儲。幾乎立即遇到以下問題:從geojson對象創建的多邊形不會顯示在地圖上。雖然由本地傳單方法創建的多邊形 - 完美地工作。Leaflet GeoJSON display
這裏是我的代碼:
var map = new L.Map('map');
var bingLayer = new L.BingLayer('AhVaalRWmmprMAMHj6lw18ALO-iVnIGzvkq7gYAX3U_bisCT8Q_lgGV25YOa0kiV', 'Aerial');
map.setView(new L.LatLng(51.505, -0.09), 13).addLayer(bingLayer);
var polygon = {
"type": "Feature",
"properties": {
"style": {
"color": "#004070",
"weight": 4,
"opacity": 1
}
},
"geometry": {
"type": "Polygon",
"coordinates": [[
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047],
[51.509, -0.08]
]]
}
};
var geojsonLayer = new L.GeoJSON(polygon);
map.addLayer(geojsonLayer);
正如你所看到的,它幾乎是拷貝一個例子,通過傳單提供。並不起作用。我完全被這個麻煩所困擾,並且非常感謝任何幫助。
這裏的文檔http://leaflet.cloudmade.com/examples/geojson.html – Karussell 2012-09-13 13:06:52
根據廣告傳單文檔(在上面的評論鏈接),所有座標似乎是(LON,LAT) – fccoelho 2014-01-27 12:02:37
你可以幫我嗎 - http://stackoverflow.com/questions/23380886/adjusting-the-drawn-object-in-map-automatically-using-leaflet-geojson-property – 2014-04-30 06:25:41