Tag Archives: Windows - Page 30

OpenLayersのVector LayerのFormat classについて[Chapter 47]

OpenLayersを使ってみる。[Chapter 47]

OpenLayersのFormat、protocolとstrategy classについて[Chapter 46] に引き続き、OpenLayersのFormat classについて基本を学んでいきます。

この章以降は、

  • どのようにvector layerを描いているか?
  • Vector Classとは?
  • GeometryとFeature classについて
  • Strategy,Protocol,Format classの使い方 → 今回もここ

について順番に学んでいきます。

OpenLayers 2.10 Beginner's Guideなる書籍の章立てにあわせて、OpenLayersの使い方を学んでいきます。

Format class

Format classはfeature dataを連続不連続で使用されます。
2つのpropertyとmethodとsubclassがあります。

Format class properties

例えば、2つの地図を表示する場合は考えます。地図の投影法は必ず2つとも一致しているとは限りません。
1つは球状のメルカトル図法を地図に使用しており、もうひとつはデータがEPSG:4326ということもあります。OpenLayerでは投影法を変換できるよう、次の2つのpropertyをセットする必要があります。

externalProjection

externalProjection: {OpenLayers.Projection} This specifies the projection that the data is in.

internalProject

internalProject: {OpenLayers.Projection} This specifies the projection that the map (or the geometries that will be returned) is in.

Format class methods

Subclassがすべて共有する2つの主要なmethodがあります。

その他のmethodについては、Format-jsを参考にしてください。

read(data)

‹read(data): Deserializes passed in data. There are other parameters that differ between subclasses. The return type also differs, but is often an array
of feature objects.

write(features)

write(features): Serializes passed in features and returns a string. The returned string will be in whatever format the format object is in—i.e., if you are using a KML format object, the returned string will be in a valid KML format.

Format subclasses

多くの利用可能なsubclassががあります。
新しいdata formatがしばしば加えられるので、OpenLayersのdocumentをチェックしてください。
現段階では、有効なsubclassは次のとおりです。

ArcXML, Atom, GeoJSON, GeoRSS, GPX, JSON, KML, OSM, OWSContext, SOSCapabilities,
Text, WFS, WKT, WMSGetFeatureInfo, WMTSCapabilities, XML

今回のまとめ

OpenLayersの簡単なFormat classについて学びました。(ちょい手抜きの部分もありますが。。。)
次回は、Strategy classについての基本を学んでいきます。

また、本tutorialは、htmlやCSSやJavaScriptの基本的なことはある程度理解している前提で今後も話を進めていきます。また、誤字、脱字、spell間違いや勘違いも多々出てくると考えられます。
それは違うじゃん!!とかいろんな意見をいただければと思います。
そこんところ ヨロシク~~!!

OpenLayers Tutorialの目次に戻る。

Social Widgets powered by AB-WebLog.com.