ContextMenuControl Examples

ContextMenuControl lets you add a comfortable context menu with just one line of code. The control is easy to embed because it doesn't require an extra panel. Instead of using a panel for displaying direction details the steps are shown in infowindows. It is possible to add up to 25 destinations for direction queries. All direction markers are draggable and removable in any order. ContextMenuControl can be invoked with or without any options. When no options are are used, all available items of the control will be shown.

  var map = new GMap2(document.getElementById("map"));
  map.setCenter(new GLatLng(37.437657, -122.157841), 12);
  map.addControl(new ContextMenuControl());

View example (simple.html).

Excluding items

ContextMenuControl currently offers the following six items to display in the context menu:'Directions from here', 'Directions to here', 'Zoom In', 'Zoom Out', 'Center Map here', and 'What's here?'. Every item provides its own functionality. By specifying one of ContextMenuControlOptions and setting its value to false you can exclude particular items of the context menu. Every item can be excluded separately. The example code below shows how to exclude the 'What's here? item:

  var map = new GMap2(document.getElementById("map"));
  map.setCenter(new GLatLng(37.437657, -122.157841), 12);
  var opts = { whatsHere: false };
  map.addControl(new ContextMenuControl( opts ));

View example (withoutWhatshere.html).