Class: ContextMenu

cercalia.ContextMenu

new cercalia.ContextMenu(opt_options)

Name Type Description
options
Name Type Description
id string | undefined optional

Contex menu identifier. If it isn't defined, will be defined in class.

map cercalia.Map | undefined optional

Map where appears the contex menu. If it isn't defined, will be defined with 'setMap' method.

fixedPosition cercalia.LonLat | undefined optional

If this argument is defined, context menu always will be shown in this position.

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 the menu.

Returns true if the option exists.

Name Type Description
id string

Option's identifier.

Returns:
True if exists.

Returns the option if exists.

Name Type Description
id string

Option's identifier.

Returns:
The option or null if not exist.

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.

Redraws the context menu.

Remove an option from the context menu and redraw it.

Name Type Description
id string

Option's identifier.

Set map of context menu

Name Type Description
map cercalia.Map

New map.