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);
导致[]空白“帮助”阵列被写入。
看来我没有访问我想要的东西。有人可以请指点我正确的方向吗?
太谢谢你了! –
如果它解决了你的问题,你会不会正式接受我的答案? :) –