ALKMaps.Control.Panel

The Panel control is a container for other controls.  With it toolbars may be composed.

Inherits from

Summary
ALKMaps.Control.PanelThe Panel control is a container for other controls.
Properties
controls{Array(ALKMaps.Control)}
autoActivate{Boolean} Activate the control when it is added to a map.
defaultControl{ALKMaps.Control} The control which is activated when the control is activated (turned on), which also happens at instantiation.
saveState{Boolean} If set to true, the active state of this panel’s controls will be stored on panel deactivation, and restored on reactivation.
allowDepress{Boolean} If is true the ALKMaps.Control.TYPE_TOOL controls can be deactivated by clicking the icon that represents them.
activeState{Object} stores the active state of this panel’s controls.
Constructor
ALKMaps.Control.PanelCreate a new control panel.
Functions
destroy
activate
deactivate
draw{DOMElement}
redraw
activateControlThis method is called when the user click on the icon representing a control in the panel.
addControlsTo build a toolbar, you add a set of controls to it.
createControlMarkupThis function just creates a div for the control.
addControlsToMapOnly for internal use in draw() and addControls() methods.
iconOnInternal use, for use only with “controls[i].events.on/un”.
iconOffInternal use, for use only with “controls[i].events.on/un”.
onButtonClick
getControlsByGet a list of controls with properties matching the given criteria.
getControlsByNameGet a list of controls with names matching the given name.
getControlsByClassGet a list of controls of a given type (CLASS_NAME).

Properties

controls

autoActivate

{Boolean} Activate the control when it is added to a map.  Default is true.

defaultControl

{ALKMaps.Control} The control which is activated when the control is activated (turned on), which also happens at instantiation.  If saveState is true, defaultControl will be nullified after the first activation of the panel.

saveState

{Boolean} If set to true, the active state of this panel’s controls will be stored on panel deactivation, and restored on reactivation.  Default is false.

allowDepress

{Boolean} If is true the ALKMaps.Control.TYPE_TOOL controls can be deactivated by clicking the icon that represents them.  Default is false.

activeState

{Object} stores the active state of this panel’s controls.

Constructor

ALKMaps.Control.Panel

Create a new control panel.

Each control in the panel is represented by an icon.  When clicking on an icon, the activateControl method is called.

Specific properties for controls on a panel

type{Number} One of ALKMaps.Control.TYPE_TOOL, ALKMaps.Control.TYPE_TOGGLE, ALKMaps.Control.TYPE_BUTTON.  If not provided, ALKMaps.Control.TYPE_TOOL is assumed.
title{string} Text displayed when mouse is over the icon that represents the control.

The ALKMaps.Control.type of a control determines the behavior when clicking its icon: ALKMaps.Control.TYPE_TOOL - The control is activated and other controls of this type in the same panel are deactivated.  This is the default type.  ALKMaps.Control.TYPE_TOGGLE - The active state of the control is toggled.  ALKMaps.Control.TYPE_BUTTON - The ALKMaps.Control.Button.trigger method of the control is called, but its active state is not changed.

If a control is ALKMaps.Control.active, it will be drawn with the olControl[Name]ItemActive class, otherwise with the olControl[Name]ItemInactive class.

Parameters

options{Object} An optional object whose properties will be used to extend the control.

Functions

destroy

destroy: function()

activate

activate: function()

deactivate

deactivate: function()

draw

draw: function()

Returns

{DOMElement}

redraw

redraw: function()

activateControl

activateControl: function (control)

This method is called when the user click on the icon representing a control in the panel.

Parameters

control{ALKMaps.Control}

addControls

addControls: function(controls)

To build a toolbar, you add a set of controls to it. addControls lets you add a single control or a list of controls to the Control Panel.

Parameters

controls{ALKMaps.Control} Controls to add in the panel.

createControlMarkup

createControlMarkup: function(control)

This function just creates a div for the control.  If specific HTML markup is needed this function can be overridden in specific classes, or at panel instantiation time:

Example

var panel = new ALKMaps.Control.Panel({
    defaultControl: control,
    // override createControlMarkup to create actual buttons
    // including texts wrapped into span elements.
    createControlMarkup: function(control) {
        var button = document.createElement('button'),
            span = document.createElement('span');
        if (control.text) {
            span.innerHTML = control.text;
        }
        return button;
    }
 });

Parameters

control{ALKMaps.Control} The control to create the HTML markup for.

Returns

{DOMElement} The markup.

addControlsToMap

addControlsToMap: function (controls)

Only for internal use in draw() and addControls() methods.

Parameters

controls{Array(ALKMaps.Control)} Controls to add into map.

iconOn

iconOn: function()

Internal use, for use only with “controls[i].events.on/un”.

iconOff

iconOff: function()

Internal use, for use only with “controls[i].events.on/un”.

onButtonClick

onButtonClick: function (evt)

Parameters

evt{Event}

getControlsBy

getControlsBy: function(property,
match)

Get a list of controls with properties matching the given criteria.

Parameters

property{String} A control property to be matched.
match{String | Object} A string to match.  Can also be a regular expression literal or object.  In addition, it can be any object with a method named test.  For regular expressions or other, if match.test(control[property]) evaluates to true, the control will be included in the array returned.  If no controls are found, an empty array is returned.

Returns

{Array(ALKMaps.Control)} A list of controls matching the given criteria.  An empty array is returned if no matches are found.

getControlsByName

getControlsByName: function(match)

Get a list of controls with names matching the given name.

Parameters

match{String | Object} A control name.  The name can also be a regular expression literal or object.  In addition, it can be any object with a method named test.  For regular expressions or other, if name.test(control.name) evaluates to true, the control will be included in the list of controls returned.  If no controls are found, an empty array is returned.

Returns

{Array(ALKMaps.Control)} A list of controls matching the given name.  An empty array is returned if no matches are found.

getControlsByClass

getControlsByClass: function(match)

Get a list of controls of a given type (CLASS_NAME).

Parameters

match{String | Object} A control class name.  The type can also be a regular expression literal or object.  In addition, it can be any object with a method named test.  For regular expressions or other, if type.test(control.CLASS_NAME) evaluates to true, the control will be included in the list of controls returned.  If no controls are found, an empty array is returned.

Returns

{Array(ALKMaps.Control)} A list of controls matching the given type.  An empty array is returned if no matches are found.

Controls affect the display or behavior of the map.
destroy: function()
activate: function()
deactivate: function()
draw: function()
{DOMElement}
redraw: function()
activateControl: function (control)
This method is called when the user click on the icon representing a control in the panel.
addControls: function(controls)
To build a toolbar, you add a set of controls to it.
createControlMarkup: function(control)
This function just creates a div for the control.
addControlsToMap: function (controls)
Only for internal use in draw() and addControls() methods.
iconOn: function()
Internal use, for use only with “controls[i].events.on/un”.
iconOff: function()
Internal use, for use only with “controls[i].events.on/un”.
onButtonClick: function (evt)
getControlsBy: function(property,
match)
Get a list of controls with properties matching the given criteria.
getControlsByName: function(match)
Get a list of controls with names matching the given name.
getControlsByClass: function(match)
Get a list of controls of a given type (CLASS_NAME).
{Boolean} If set to true, the active state of this panel’s controls will be stored on panel deactivation, and restored on reactivation.
{ALKMaps.Control} The control which is activated when the control is activated (turned on), which also happens at instantiation.
{Number} Controls can have a ‘type’.
trigger: function()
Called by a control panel when the button is clicked.
{Boolean} The control is active (read-only).
Close