0
我正努力爲D01創建一個數組值。這是我以GeoJSON變量的第一個特點:從geojson中提取數值的問題
county = [{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4269" } },
"features": [
{ "type": "Feature", "properties": { "NAMELSAD10": "St. Clair County", "D01": 5.650500, "D02": 0.504000, "D03": 0.495000, "D04": 48.100000, "D05": 0.199000, "D06": 0.965000, "D07": 0.038000, "D08": 0.031000, "D09": 0.211000 }, "geometry": { "type": "Polygon", "coordinates": [
//so many coordinate pairs
] } } ] ]
爲了澄清,我想[5.650500,...]
從this post我用:
help = county.features.map(function(f){
return f.properties.D01;
})
這給錯誤:無法讀取未定義的屬性「地圖」。
思考我的一些值可能爲空,我寫了這個:
var help = new Array();
try{
help = county.features.map(function(f){
return f.properties.D01;
})
}catch(e){}
console.log(help);
導致[]空白「幫助」陣列被寫入。
看來我沒有訪問我想要的東西。有人可以請指點我正確的方向嗎?
太謝謝你了! –
如果它解決了你的問題,你會不會正式接受我的答案? :) –