Class: ContextMenu

cercalia.ContextMenu


Class for creating a context menu. This control permits:

  • Draw a menu in a LatLng position.
  • Add / Remove options in menu.
  • Enable / Disable options of the menu.
  • Show / Hide options of the menu.

new cercalia.ContextMenu(opt_options)

src/cercalia/contextmenu.js, line 21
Name Type Description
options

Options.

Name Type Description
id string | undefined

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

map cercalia.Map | undefined

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

fixedPosition cercalia.LonLat | undefined

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

Extends

Methods

addOption(id, name, callback, opt_position)

src/cercalia/contextmenu.js, line 113

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.

addSubMenu(id, name, optionList)

src/cercalia/contextmenu.js, line 148
Name Type Description
id string

Specify internal Id element

name string

Label of submenu.

optionList cercalia.ContextMenuSubmenuOptionList

Option list. Example: {[{id:'btn1', label:'Button1', callback: 'callbackFn1'}, {id:'btn2', label:'Button2', callback: 'callbackFn1'}]}.

close()

src/cercalia/contextmenu.js, line 172

Close the menu.

closeSubmenu(id)

src/cercalia/contextmenu.js, line 277

Close Submenu

Name Type Description
id string

Id.

existOption(id){boolean}

src/cercalia/contextmenu.js, line 183

Returns true if the option exists.

Name Type Description
id string

Option's identifier.

Returns:
True if exists.

getClass(){string} inherited

src/cercalia/object.js, line 41
Returns:
Get Class name of object

getId(){string} inherited

src/cercalia/object.js, line 33
Returns:
Unique Id.

hideOption(id)

src/cercalia/contextmenu.js, line 259

Hide menu option.

Name Type Description
id string

Id.

isVisible(){boolean}

src/cercalia/contextmenu.js, line 100

Returns true if the context menu is visible.

Returns:
Returns true if is visible.

open(coordinates, opt_projection)

src/cercalia/contextmenu.js, line 193

Open the menu. If menu isn't position fixed needs a position to be displayed.

Name Type Description
coordinates Array.<number> | cercalia.LonLat

If menu isn't position fixed, menu will be displayed in ths position.

projection string

If menu isn't position fixed, and coordinates are Array of numbers, the projection will be necesary to transform the position.

openSubmenu(id)

src/cercalia/contextmenu.js, line 268

Open Submenu

Name Type Description
id string

Id.

removeAllOptions()

src/cercalia/contextmenu.js, line 224

Remove all options in context menu.

removeOption(id)

src/cercalia/contextmenu.js, line 238

Remove an option from the context menu.

Name Type Description
id string

Option's identifier.

showOption(id)

src/cercalia/contextmenu.js, line 250

Show menu option.

Name Type Description
id string

Id.