O'Reilly logo

Google Maps JavaScript API Cookbook by Balkan Uraz, Alper Dincer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting the coordinates of a mouse click

The mouse has been the most effective input device for computers for a long time. Nowadays, there is an attempt to change it with touchscreens, but nothing can be compared to the ease of use that a mouse provides.

The mouse has different interactions on maps, such as click, double-click, right-click, move, and drag. These events can be handled in different ways to interact with users.

In this recipe, we will get the coordinates of a mouse click on any point on the map. Users will see an info window upon a mouse click, which can be seen in the following screenshot:

Getting the coordinates of a mouse click

This is how we achieve the creation of a map ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required