Nokia Maps API Reference

Contents

Class nokia.maps.map.component.ContextMenu

Class Summary

The context menu allows to display a context menu on the map. By default the context menu contains two entries that allow to zoom the map in and out by one zoom level.

The context menu may be extended by adding handlers to the context menu, which allow to add entries to a group which is unique to the handler. Entries may contain a label and a callback for that action that is to be invoked on activation of the respective entry.

Examples:
var myHandler = function(contextMenuEvent, group) {
	group.addEntry(
		"pan left",
		function(activationEvent) {
			this.mapDisplay.pan(0, 0, -200, 0);
		});
}

var contextMenu = new nokia.maps.map.component.ContextMenu();
contextMenu.addHandler(myHandler);

display.components.add(contextMenu);
Group The ContextMenu.Group class represents an abstract group of entries within the context menu.
Method Summary
addHandler (handler) This method adds a user-defined handler to the context menu.
addObserver (key, callback, [context]) : nokia.maps.util.OObject This method registers an observer for the property named by the caller.
attach (mapDisplay) This method is a callback invoked when the component is attached to a map.
destroy () This method is called from Display when Display is destroyed.
detach (mapDisplay) This method is a callback invoked when the component is detached from a map.
get (key) : Variant This method retrieves the value of the property with the name provided by the caller.
getId () : String This method retrieves the unique identifier of the component.
getVersion () : String This method retrieves the version of the component.
queryReference () : nokia.maps.map.component.Component This method incremements the component's reference count.
releaseReference () : Number This method release a reference to the given component by decrementing the reference count.
remove (key) : nokia.maps.util.OObject This method removes the property with the name provided by the caller.
removeHandler (handler) This method removes a previously added handler from the context menu.
removeObserver (key, callback, context) : nokia.maps.util.OObject This method removes the observer for the property named by the caller.
set (nameOrObject, [value, [force]]) : nokia.maps.util.OObject This method sets property values, using the property names and values supplied by the caller.
Field Summary
nokia.maps.map.Display mapDisplay This property holds a reference to the map.Display instance to which the given component belongs.
Constructor Detail

This method initializes a new instance of ContextMenu

new nokia.maps.map.component.ContextMenu()
Examples:
var myHandler = function(contextMenuEvent, group) {
	group.addEntry(
		"pan left",
		function(activationEvent) {
			this.mapDisplay.pan(0, 0, -200, 0);
		});
}

var contextMenu = new nokia.maps.map.component.ContextMenu();
contextMenu.addHandler(myHandler);

display.components.add(contextMenu);
Method Detail
addHandler (handler)
This method adds a user-defined handler to the context menu. The handler callback is called with the event that activated the context menu and a group that is unique to the the handler function. To add entries invoke the addEntry() method (nokia.maps.map.component.ContextMenu.Group#addEntry).
Parameters:
{Function} handler
removeHandler (handler)
This method removes a previously added handler from the context menu.
Parameters:
{Function} handler
Documentation generated on Tue May 08 2012 10:23:55 GMT+0200 (CEST).