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 ...

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.