OpenLayersのMap Class Propertiesについて-5[Chapter 31]

====== OpenLayersを使ってみる。[Chapter 31] ======

[[http://blog.godo-tys.jp/2013/07/26/3340/|OpenLayersのMap Class Propertiesについて-4[Chapter 30] ]]に引き続き、OpenLayersの**Map Class Properties**についての基本を学んでおきます。

[[http://www.packtpub.com/openlayers-2-1-javascript-web-mapping-library-beginners-guide/book|OpenLayers 2.10 Beginner’s Guide]]なる書籍の章立てにあわせて、OpenLayersの使い方を学んでいきます。

OpenLayers Mapについての詳細は、[[http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map|OpenLayers.Map ]]を参考にしてください。

===== Map class properties =====

ここでは、Map classのよく使うpropertiesについて学んでいきます。すべてのpropertiesについては、
[[http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map|OpenLayers.Map ]]を参考にしてください。

==== Map propteries ====

[[http://blog.godo-tys.jp/2013/07/24/3332/|OpenLayersのMap Class Propertiesについて-3[Chapter 29] ]]に引き続き、OpenLayersの**Map Class Properties**について引き続き、Map propertiesを学びます。

=== panMethod ===

Pan(移動)のpropertiesです。Panをanimationっぽく動かします。
ただ、あまり使ったことがないので、なんとも。。。

**panMethod: {Function}**
panMethodのanimationを定義します。Deafultは、**OpenLayers.Easing.Expo.easeOut**となっています。ほかには、OpenLayers.Easing.Quad.easeInOutがありますが、詳しくは、[[http://dev.openlayers.org/docs/files/OpenLayers/Tween-js.html|OpenLayers.Tween]]を参考にしてください。

=== panDuration ===

**panDuration: {Integer} Default: 50**
**panDuration**は、panのclick時の移動を定義します。Defaultは50となっています。

ここで、上記のpropertiesを使ってexample codeを実行してみましょう。

=== pan animation example code ===

Panのanimationですので、jsfiddleを使ってみましょう。
**Result**をclickすると、Mapが表示されます。

[iframe width=”100%” height=”500″ src=”http://jsfiddle.net/godo_tys/9rNUR/6/embedded/” allowfullscreen=”allowfullscreen” frameborder=”0″]
[/iframe]

順に上記codeを見ていきましょう。
まずは、Map objectの作成を行います。

//Create a map with an empty array of controls
map = new OpenLayers.Map('map_element', {
controls : [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher()],
panMethod : OpenLayers.Easing.Quad.easeInOut,
//panMethod : OpenLayers.Easing.Expo.easeOut,
panDuration : 100
});

panMethodを設定しています。

**Edit jsfiddle**でコメントを入れ替えて、pan animationの違いを確認してください。

=== projection ===

**projection: {String} **
**projection**は地図の投影法です。Defaultでは、**’EPSG:4326’**です。度表示になります。
このprojectionは、maxExtent、maxResolution、unitsに関係してきます。

=== theme ===

**theme: {String or null}**
Defaultでは、**’theme/default/style.css’**です。
ほかにcssを変更することで、themeを代えることができます。

=== tileSize ===

**tileSize: {OpenLayers.Size}**
**tileSize**は、defaultではGooglsmaps APIのように(256px,256px)となっています。
Tile cache serverに仕様にもよりますが、(512px,512px)のようにoverrideして定義することもできます。
そのときは、

tileSize: new OpenLayers.Size(512,512);

のように定義します。

=== unit ===

**unit: {String}**
**unit**は、mapの単位になります。Defaultでは、**’degrees’**で「度」になります。
利用可能は**unit**は、**’degrees’** または **’dd’**, **’m’**, **’ft’**, **’km’**, **’mi’**, **’inches’**となります。Projectionより**unit**を変更することができます。

===== 今回のまとめ =====

OpenLayersの**Map class property**の基本について概要を学びました。
次回は、Map class functionについて学んでいきます。

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

**[[http://blog.godo-tys.jp/openlayer-tutorial/|OpenLayers Tutorialの目次に戻る。]]**

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

CAPTCHA