Daily Archives: 06/29/2013

OpenLayersのControl Classについて[Chapter 19]

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

OpenLayersのControlについて[Chapter 18] に引き続き、OpenLayersのControl Classについての基本を学んでおきます。

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

OpenLayer.Control Class

他のClassと同様に、OpenLayers.Controlの基本ClassのPropertyとFunctionを持っています。

OpenLayers Controlについての詳細は、OpenLayers.Control を参考にしてください。

OpenLayers.Control Properties

インスタンス化するときに他のclassのpropertiesと同様に、これらのpropertiesを指定することができ、objectを制御します。
OpenLayers.Control Classの代表的なものは、
(ここでは、原文のまま載せます。)

Name Typs Description
autoActivate {Boolean} Set the control to activate when added to the map.Default value is false.
div {HTMLElement} Many controls support the ability to be placed in a div outside the map. (This does not work for all controls, however.) An example call would look like: {div:document.getElementById('my_control_div') }
id {String} This specifies the ID of the HTML element that will be assigned to the control.
eventListeners {Object} This object specifies event listeners to register. Events are covered later in this chapter.
displayClass {String} Specifies the CSS class that the control will receive. By default, controls receive a class name made up of OlControl plus the control name, e.g. OlControlNavToolBar. We cover this in more detail in Chapter 7 on styling controls.
title {String} The title you set here will be displayed in a tooltip (or other places, when appropriate).
type {Number} Specifies the type of control, which is related to how the control functions.Used in various cases, such as when working with buttons or panels. We cover this later in the chapter, on the section on panels.

OpenLayers.Control Function

すべてのControl Subclassは、次の表の関数を継承します。
OpenLayers.Control Functionの代表的なものは、
(ここでは、原文のまま載せます。)

Name Description
destroy() This will perform any clean up actions (such as removing any events attached to the control) and then remove the control from the map. Since the control is removed from the map, it also will no longer show up when accessing map.controls.
moveTo(location) This function takes in a single parameter, location, an OpenLayers.Pixel object, and will move the control to the passed in pixel coordinate (in the order of x coordinate, y coordinate). This function will only really affect controls which have a visible component. An example call might be: control_object.moveTo(new OpenLayers.Pixel(200,100)); which would move the control to the x, y, position of 200, 100 inside of the map. The origin is the top left of the map, so it would move 200 pixels to the right and 100 pixels down.
activate() Calling this function will activate the control and its event handler (if one is set). Returns true if control was successfully activated and false if it was already active.
deactivate() Deactivates the control and any associated event handlers. The behavior of this will vary among controls. Returns true if control was successfully deactivated and false if it was already inactive.
draw() This function initializes the control. You will rarely have to call this, as it is usually called automatically. There may, however, be cases where you may want to issue the call manually. It returns a {DOMElement} which is a reference to the div containing the control (if one exists).

今回のまとめ

OpenLayersによるContorl ClassのPropertiesとFunctionの基本について学びました。(ずいぶん手抜きでないかい?)
次回は、OpenLayers Control Subclassの詳細について学んでいきます。

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

OpenLayers Tutorialの目次に戻る。

1 / 11

Social Widgets powered by AB-WebLog.com.