ALKMaps.Control.ContextMenu

The context menu control allows you to create a right-click menu to expose any custom functions.

Example

new ALKMaps.Control.ContextMenu({
    'ctxMenuItems': [
        { separator: false, text: 'Zoom In', onclick: function(evt) { alert(evt); }},
        { separator: true },
        { separator: false, text: 'Zoom Out', onclick: function(evt) { alert(evt); }}
     ],
})

This will produce a menu like this:

Inherits from

Summary
ALKMaps.Control.ContextMenuThe context menu control allows you to create a right-click menu to expose any custom functions.
Properties
handleRightClicks{Boolean} Whether or not to handle right clicks.
autoActivate{Boolean} Activate the control when it is added to a map.
ctxMenuItems
menuItemsObsolete.
Constructor
ALKMaps.Control.ContextMenuCreate a new context menu control
Functions
destroyThe destroy method is used to perform any clean up before the control is dereferenced.
activateActivates the control.
deactivateDeactivates the control.
setMapSet the map property for the control, and register map events.
drawThe draw method is called when the control is ready to be displayed on the page.
showMenuDisplays the context menu at the specified location.
hideMenuHides the context menu.

Properties

handleRightClicks

{Boolean} Whether or not to handle right clicks.

autoActivate

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

ctxMenuItems

{Object}{ ‘ctxMenuItems’: [ { separator: false, text: ‘Zoom In’, onclick: function(ex) { alert(ex); }}, { separator: true }, { separator: false, text: ‘Zoom Out’, onclick: function(ex) { alert(ex); }} ] }

menuItems

Obsolete.  Backward compatible with old api.  {Object} - { ‘Zoom In’:’map.zoomIn()’, ‘Zoom Out’:’map.zoomOut()’, ‘separator’:true, ‘Zoom to Extent’:’map.zoomToMaxExtent()’ }

Constructor

ALKMaps.Control.ContextMenu

Create a new context menu control

Parameters

items{Object}
options{Object} An optional object whose properties will be set on the control

Functions

destroy

destroy: function ()

The destroy method is used to perform any clean up before the control is dereferenced.

activate

activate: function ()

Activates the control.

Returns

{Boolean} The control was effectively activated.

deactivate

deactivate: function ()

Deactivates the control.

Returns

{Boolean} The control was effectively deactivated.

setMap

setMap: function (map)

Set the map property for the control, and register map events.

Parameters

map{ALKMaps.Map}

draw

draw: function()

The draw method is called when the control is ready to be displayed on the page.

Returns

{DOMElement} A reference to the DIV DOMElement containing the control

showMenu

showMenu: function(loc)

Displays the context menu at the specified location.

Parameters

loc{Array<Number>} Pixel coordinates

hideMenu

hideMenu: function ()

Hides the context menu.

destroy: function ()
The destroy method is used to perform any clean up before the control is dereferenced.
activate: function ()
Activates the control.
deactivate: function ()
Deactivates the control.
setMap: function (map)
Set the map property for the control, and register map events.
draw: function()
The draw method is called when the control is ready to be displayed on the page.
showMenu: function(loc)
Displays the context menu at the specified location.
hideMenu: function ()
Hides the context menu.
Controls affect the display or behavior of the map.
Instances of ALKMaps.Map are interactive maps embedded in a web page.
Close