2012-01-11 129 views

回答

6

规范并不禁止这样明确,但是要素集合不具备的特性。以GeoJSON规范只提到了的FeatureCollection以下键:

  • type - 必须是`的FeatureCollection
  • features - feaures
  • bbox的阵列 - 边界全要素集合

的框,我请参阅OpenLayers代码,properties仅针对要素实例进行处理,而不针对要素集合进行处理。

2

切换到单张更容易,它接受GeoJSON的用的FeatureCollection。当您单击对象时,您还可以获取Popup中的属性。

但是,Openlayers也可以访问FeatureCollection。 Mobile(jQuery Mobile)Openlayers示例演示了访问属性。

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]} 
     } 
    ] 
}