1
解析JSON數據
我的代碼是這樣的Mapbox問題與熱圖
heat = L.heatLayer([], { maxZoom: 12 }).addTo(map);
$.getJSON("js/example-single.geojson", function(data) {
var geojsosn = L.geoJson(data, {
onEachFeature: function (feature, layer) {
console.log(feature.geometry.coordinates[0] ,feature.geometry.coordinates[1]);
heat.addLatLng(feature.geometry.coordinates[0], feature.geometry.coordinates[1]);
}
});
,但我得到一個錯誤「遺漏的類型錯誤:無法讀取屬性‘緯度’的未定義」
請告訴如何解決這一問題如果我的代碼是錯誤的有人告訴我如何解析JSON數據的熱圖中mapbox
的json數據是
{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [13.353323936462402, 38.11200434622822]},
"properties": {"marker-color": "#000"}
}
]
}
感謝他的工作 – Anish 2014-10-30 11:49:38