new alk.control.ContextMenu(opt_options)
This constructor creates a control that may be added to the Open Layers Map.
| Option | Type | Description |
|---|---|---|
ctxMenuItems |
Array.<alkx.ContextMenuOptionItem> | undefined | |
menuItems |
Object.<string, (string|boolean)> | undefined |
Example
var map = new ol.Map();
var menu = new alk.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); }}
],
});
map.addControl(menu);
Extends
- ol.control.Control
Members
-
autoActivate{boolean}
-
Activates the control when it is added to a map. Default is true.
-
ctxMenuItems{Object}
-
Contains the context menu items.
-
handleRightClicks{boolean}
-
This property configures the menu to handle right clicks. Default is true;
-
items{Array.<{index: (number), callback: (function()|undefined), separator: (boolean), name: (string|undefined), onclick: (boolean|string|undefined)}>}
-
Methods
-
closeMenu()
-
This method hides the context menu.
-
openMenu(pixel, coordinate)
-
Opens the menu given the coordinate and its corresponding pixel position.
Name Type Description pixelol.Pixel coordinateol.Coordinate -
positionContainer(pixel)
-
Update the mouseposition element.
Name Type Description pixelol.Pixel The pixel on which the right click happened.
-
render(mapEvent)
-
Update the mouseposition element.
Name Type Description mapEventol.MapEvent Map event.
-
setMap(map)
-
Remove the control from its current map and attach it to the new map. Subclasses may set up event handlers to get notified about changes to the map here.
Name Type Description mapol.PluggableMap Map.