new cercalia.ContextMenu(opt_options)
| Name | Type | Description |
|---|---|---|
options |
cercaliax.ContextMenuOptions |
Methods
-
addOption(id, name, callback, position){string}
-
Add a new option in the context menu at the end or in a specific position. Returns options identifier. If the id options exist removes previous option.
Name Type Description idstring Option's identifier.
namestring Text will be displayed in option.
callbackfunction Function will be fired when users click the option.
positionnumber The position where option will be added.
Returns:
Options identifier.
-
close()
-
Close the menu.
-
existOption(id){Boolean}
-
Returns true if the option exists.
Name Type Description idstring Option's identifier.
Returns:
True if exists.
-
findOptionById(id){Object}
-
Returns the option if exists.
Name Type Description idstring Option's identifier.
Returns:
The option or null if not exist.
-
isVisible(){Boolean}
-
Returns true if the context menu is visible.
-
open(coordinates, projection)
-
Open the menu. If menu isn't position fixed needs a position to be displayed.
Name Type Description coordinatesArray.<number> | cercalia.LonLat | undefined optional If menu isn't position fixed, menu will be displayed in ths position.
projectionstring | undefined optional If menu isn't position fixed, and coordinates are Array of numbers, the projection will be necesary to transform the position.
-
redraw()
-
Redraws the context menu.
-
removeOption(id)
-
Remove an option from the context menu and redraw it.
Name Type Description idstring Option's identifier.
-
setMap(map)
-
Set map of context menu
Name Type Description mapcercalia.Map New map.