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 id
string Option's identifier.
name
string Text will be displayed in option.
callback
function Function will be fired when users click the option.
position
number 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 id
string Option's identifier.
Returns:
True if exists.
-
findOptionById(id){Object}
-
Returns the option if exists.
Name Type Description id
string 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 coordinates
Array.<number> | cercalia.LonLat | undefined optional If menu isn't position fixed, menu will be displayed in ths position.
projection
string | 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 id
string Option's identifier.
-
setMap(map)
-
Set map of context menu
Name Type Description map
cercalia.Map New map.