Creating a context menu on a map

Using menus in a user interface is a way to communicate with users. Users select a menu item to interact with web applications. Some of the menu types can be accessible from a visible place, but some of them can be accessible with some extra actions, such as context menus. Context menus usually appear on applications with a right-click of the mouse.

In this recipe, we will create a context menu on the map that opens when we right-click on the map. This menu includes zoom in, zoom out, and add marker functions. You will also get the position of the right-click to use it in some geo methods such as adding a marker in this example.

Getting ready

This recipe is also like the other recipes in that we assume you already ...

Get Google Maps JavaScript API Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.