ContextMenu 1.0 Reference | ||
---|---|---|
ContextMenu is a context menu for Google Maps API v3. The menu and it's actions are fully configurable. When you create an instance of ContextMenu you define the menu items that your application requires. A click on a menu item will trigger an event menu_item_selected and pass the menu's position (a LatLng object) and the clicked menu item's eventName to any event listener. ContextMenu is a custom overlay object that implements the google.maps.OverlayView interface. |
ContextMenu object | ||
---|---|---|
Constructor | Description | |
ContextMenu(map:google.maps.Map, contextMenuOptions:ContextMenuOptions) |
Creates a ContextMenu using the ContextMenuOptions object and adds it to the Map map. The ContextMenu will be hidden until it's show() method is executed. |
|
Method | Return Value | Description |
getVisible() | boolean | Gets the visible state of the ContextMenu |
hide() | None | Hides the ContextMenu |
show(position:google.maps.LatLng) | None | Sets the ContextMenu's position and makes it visible. |
Event | Arguments | Description |
menu_item_selected | google.maps.LatLng, string |
This event is triggered when the user clicks a menu item. An event listener will be passed the ContextMenu position and the clicked menu item's eventName |
ContextMenuOptions object | ||
---|---|---|
ContextMenuOptions has no constructor, it is implemented as an object literal. | ||
Property | Type | Description |
classNames | object literal |
Optional. It has two optional string properties: menu and menuSeparator. These CSS classNames will be applied to the menu which is the ContextMenu's main HTML element, and to any menuSeparators which are non-clickable spacer elements in the menu list. |
menuItems | Array of ContextMenuItem |
Required. Defines the menu items that will be added to the ContextMenu. |
pixelOffset | google.maps.Point |
Optional. Defines an offset at which to display the ContextMenu relative to the ContextMenu's position. |
ContextMenuItem object | ||
---|---|---|
ContextMenuItem has no constructor, it is implemented as an object literal. | ||
Property | Type | Description |
className | string |
Optional. A CSS className to apply to the clickable menu item. |
eventName | string |
Required. An identifier passed to any menu_item_selected event listener. |
id | string |
Optional. A CSS id to apply to the clickable menu item. |
label | string |
Required. The text to display in the clickable menu item. |
Alternatively use an object with no properties {} as a ContextMenuItem and a menuSeparator will be created. |