Creating a control that shows coordinates

Geographical coordinates are very important for showing where you are on the earth. Latitudes and longitudes come together to create a two-dimensional grid that simulates the earth's surface. Showing the latitude and longitude in a control on the map while you are moving the mouse can be a good usage of controls and events together.

In Chapter 4, Working with Controls, we have seen recipes such as Adding your own logo as a control, and we have also seen how to use map events in this chapter. In this recipe, we will create a control with the help of the mousemove event of the map that shows the coordinates in real time.

Getting ready

In this recipe, we will use the first recipe defined in Chapter 1, Google ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.