引用geoJSON文件中的数据
Referencing data in a geoJSON file
JS新手。
if (kcdfp_parcel[i].InActive == 0)
数据是一个geoJSON文件,变量为"kcdfp_parcel"。
这是一小段文件:
kcdfp_parcel = [{"类型":"FeatureCollection","crs":{"类型":"名字","属性":{"名称":" urn: [: def: crs: [: 1.3: CRS84"}},
"features": [
{ "type": "Feature", "properties": { "MAJOR": "000440", "MINOR": "0018", "PIN": "0004400018", "FarmID": 3101.000000, "LastName": "Codiga", "Acres": 62.940000, "Cooperativ": null, "InActive": 0, "ParcelNumb": "0004400018", "Shape_Leng": 0.024319, "Shape_Area": 0.000030 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.254601971999989,
我引用LastName字段正确(例如,我需要使用kcdfp_parcel.features.InActive)?
或者,我的IF语句错了吗?
应该能够像下面的例子一样通过kcdfp_parcel.features[some_index].properties.InActive
引用"InActive"。通过console.log
在浏览器控制台上输出如下所示:
特征索引0的属性InActive为0,ParcelNumb为0004400018
特征索引1有属性InActive为0和ParcelNumb0006400009
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<body>
<h1>Check your browser console...</h1>
</body>
<script type="text/javascript">
var kcdfp_parcel = {
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": "…"
}
},
"features": [
{
"type": "Feature",
"properties": {
"InActive": 0,
"ParcelNumb": "0004400018"
},
"geometry": {
"type": "Polygon",
"coordinates": [ [ [ -122.254601971999989, 47.364317413000038 ], [ -122.254231611999955, 47.364320569000029 ] ] ]
}
},
{
"type": "Feature",
"properties": {
"InActive": 0,
"ParcelNumb": "0006400009"
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [ [ [ -122.059132819999945, 47.197189012000081 ], [ -122.059119953999982, 47.197182407000071 ] ] ]
}
}
]
};
for (var i = 0; i < kcdfp_parcel.features.length; i++) {
console.log("Features index " + i + " has property InActive of " + kcdfp_parcel.features[i].properties.InActive +
" and ParcelNumb of " + kcdfp_parcel.features[i].properties.ParcelNumb);
}
</script>
</html>
相关文章:
- 如何使用.log数据文件显示EXT-js网格
- 如何在javascript中使用会话特定的数据文件
- 数据文件出现 D3 错误
- HTML 对象数据文件(如果未找到)
- 在 JSFiddle 中链接外部 JSON 数据文件
- 如何从 SDK 插件数据文件夹加载 DLL
- 使用 jquery 从 json 数据文件动态填充选择元素
- 节点模块包括数据文件作为全局变量
- 如何获取 HTML 标记的“数据文件”属性的内容
- 在 d3.js 散点文件中使用数据数组而不是外部数据文件
- 我用PHP调用的数据文件神秘地被更改了.用户是否覆盖了它
- 从数据文件导入数组
- 谷歌驱动器API应用程序数据文件夹,是真的那么困难
- XML数据文件已更改,但更改不会;t出现在gmaps中的html页面上
- 大文件(超过~2Mb)上传-引发错误“;键'数据文件'在<MultiValueDict:{}>
- 将数据文件转换为blob
- 如何使用链接检索整个数据文件(ajax?)
- firefox(9),javascript,由于大数据文件导致分配大小溢出.有什么办法可以避免这种情况吗
- 我们可以在json数据文件中添加图像,并使用D3.js在页面上调用它
- IANA (Internet Assigned Numbers Authority)数据文件和来自www.timeand