我在规范中找不到任何相关信息:http: //geojson.org/geojson-spec.html
是否允许properties
在 a 中有密钥FeatureCollection
?还是只有功能才有可能?
如果可能,我如何访问其中的属性openlayers
?提前致谢。
我在规范中找不到任何相关信息:http: //geojson.org/geojson-spec.html
是否允许properties
在 a 中有密钥FeatureCollection
?还是只有功能才有可能?
如果可能,我如何访问其中的属性openlayers
?提前致谢。
规范没有明确禁止它,但特征集合没有属性。GeoJSON 规范仅提及 FeatureCollection 的以下键:
type
- 必须是 `FeatureCollectionfeatures
- 一系列功能bbox
- 整个特征集合的边界框正如我从 OpenLayers 代码中看到的,properties
仅针对功能实例进行处理,而不针对功能集合进行处理。
切换到 Leaflet 更容易,它接受带有 FeatureCollection 的 GeoJSON。当您单击对象时,您也可以在弹出窗口中获取属性。
但是,Openlayers 也可以访问 FeatureCollection。Openlayers 的 Mobile (jQuery Mobile) 示例演示了访问属性。
http://openlayers.org/dev/examples/mobile-jq.html#mappage
单击黑色图标,您将看到带有这些属性的弹出表单。
这是移动示例中 GeoJSON 的一部分。
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point","coordinates": [1332700, 7906300]},
"properties": {"Name": "Igor Tihonov","Country":"Sweden", "City":"Gothenburg"}
},
{ "type": "Feature",
"geometry": {"type": "Point","coordinates": [790300, 6573900]},
"properties": {"Name": "Marc Jansen","Country":"Germany", "City":"Bonn"}
},
{ "type": "Feature",
"geometry": {"type": "Point","coordinates": [568600, 6817300]},
"properties": {"Name": "Bart van den Eijnden","Country":"Netherlands", "City":"Utrecht"}
},
{ "type": "Feature",
"geometry": {"type": "Point","coordinates": [-7909900, 5215100]}
}
]
}