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

Creating and adding a geolocation control

The Google Maps UI has many built-in controls introduced in previous recipes. These controls serve numerous needs, such as panning, zooming, and changing the map type. However, the user needs are infinite, and the user might be very creative. It is impossible to present a built-in control for every need.

Instead, the Google Maps JavaScript API has presented a path for creating custom controls for every specific need. Custom controls are basically simple HTML elements wrapped in a single element, mostly the <div> element.

In this recipe, we will go over the basics of creating a custom control, placing it on the Google Maps UI, and using it through event-handling routines.

Getting ready

This recipe will be based ...

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