OpenLayersを使ってみる。[Chapter 9]
OpenLayersのLayer Objectについて[Chapter 8] に引き続き、OpenLayersのLayer Class Mtthodについて学んでみます。
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してみてください。こちらの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. | - |
詳しくは、OpneLayers.LayerのFunction(method)を参照してください。
OpenLayers-2.10は、OpneLayers.LayerのFunction(method)を参照してください。
今回のまとめ
OpenLayersによるLayer Class Methodの基本を学びました。
次回は、Layerの最後で、Map Tilesについて学んでいきます。
また、本tutorialは、htmlやCSSやJavaScriptの基本的なことはある程度理解している前提で今後も話を進めていきます。また、誤字、脱字、spell間違いや勘違いも多々出てくると考えられます。
それは違うじゃん!!とかいろんな意見をいただければと思います。
そこんところ ヨロシク~~!!
最近のコメント