8

仕様に関連情報が見つかりませんでした: http://geojson.org/geojson-spec.html

propertiesにキーを入れることはできFeatureCollectionますか? それとも機能のみ可能ですか?

可能であれば、内のプロパティにアクセスするにはどうすればよいopenlayersですか? 前もって感謝します。

4

2 に答える 2

10

仕様では明示的に禁止されていませんが、フィーチャ コレクションにはプロパティがありません。GeoJSON 仕様では、FeatureCollection の次のキーのみが言及されています。

  • type- `FeatureCollection でなければなりません
  • features- 機能の配列
  • bbox- 機能コレクション全体の境界ボックス

OpenLayers コードからわかるようにproperties、機能コレクションではなく、機能インスタンスに対してのみ処理されます。

于 2012-01-11T14:54:10.793 に答える
-2

Leaflet への切り替えは簡単で、FeatureCollection で GeoJSON を受け入れます。オブジェクトをクリックすると、ポップアップの属性も取得できます。

ただし、Openlayers も FeatureCollection にアクセスします。Openlayers のモバイル (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]}
        }
    ]
}
于 2012-04-04T05:05:57.173 に答える