OpenLayersのLayer Class Methodsについて[Chapter 9]

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

[[http://blog.godo-tys.jp/2013/06/03/2040/|OpenLayersのLayer Objectについて[Chapter 8] ]]に引き続き、OpenLayersのLayer Class Mtthodについて学んでみます。
[[http://www.packtpub.com/openlayers-2-1-javascript-web-mapping-library-beginners-guide/book|OpenLayers 2.10 Beginner’s Guide]]なる書籍の章立てにあわせて、OpenLayersの使い方を学んでいきます。

本Blog中のsource code等に関しては、あくまでも参考としてください。なにがあっても責任とれませんので。
そこんところ、ヨロシク~~!!

===== Layer Class Method =====

ここまでで、Layer Classを学んできました。
ここでLayerの最後は、Base Layerの機能とmethodです。
ここでの機能とmethodはSubclassにすべて継承され、使用することができます。

===== Layer Class Methodの定義 =====

非常に多くのlayer Class Methodがあります。
とりえず、原文のまま載せておきます。 日本語に訳せば良いのでしょうが、それほど難しいものはないので、各自翻訳にtryしてみてください。こちらの[[http://mapabc.wikidot.com/openlayers:ref-openlayers-layer#toc31|OpenLayers.Layer method]]が非常に参考になります。**先人に感謝です。**

^Function ^Description/Action ^parameters ^Return Value^
|setName( newName ) |Set a new name for the layer based on the passed in string. This will also update the display name for the layer in the layer switcher control, and may trigger a changelayer event. |newName:{String} The new name of the layer. |-|
|addOptions( options ) |Add additional options to the layer. The parameter behaves like the options parameter, and allows you to set properties on the layer. |options: {Object} An anonymous object containing key:value pairs of layer properties and values. |-|
|redraw() |Redraws the layer.Returns true if the layer was successfully redrawn or false if the layer could not be redrawn.You will need to call thiswhile adding features to a vector layer, as we’ll cover in Chapter 9. |- |{Boolean}|
|getVisibility() |Checks if the layer is visible or not. Returns true if the layer is visible, false if not. |- |{Boolean}|
|SetVisibility( visibility ) |Sets the visibility to true or false, hide/show the layer, and redraw it. The visibility determines if a layer should be shown or not. |visibility:{Boolean} true to show the layer,false to hide the layer. |-|
|calculateInRange() |Returns true or false if the layer can be displayed at the map’s current resolution. If the alwaysInRange property is true, this will always return true. |- |{Boolean}|
|setIsBaseLayer( is_base )|Will turn the layer into a base layer if true is passed in and false is passed in it will no longer make it a base layer. |is_base: {Boolean} Set to true to make layer a base layer, false to make it an overlay layer. |-|
|setOpacity( opacity ) |Sets the opacity of a layer based on the value passed in. The passed in opacity value is a float with valid values from 0 to 1, with 0 being completely ransparent and 1 being fully opaque. 0.5 would be 50 percent transparent. |opacity: {Float} Value of desired opacity. |-|

詳しくは、[[http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.Functions|OpneLayers.LayerのFunction(method)]]を参照してください。
OpenLayers-2.10は、[[http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.Functions|OpneLayers.LayerのFunction(method)]]を参照してください。

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

OpenLayersによる**Layer Class Method**の基本を学びました。
次回は、Layerの最後で、**Map Tiles**について学んでいきます。

また、本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