๐Ÿก Home ๐Ÿ“– Chapter ๐Ÿ‘ˆ Prev ๐Ÿ‘‰ Next

โšกย  GMapsBook.com is crafted by Jozef Sorocin (๐ŸŸขย Book a consulting hour) and powered by:

Once youโ€™ve grasped the concepts behind Dragging & Editing, you can delight your users by letting them draw on your Google map.

Drawing on the map canvas enables a variety of use cases. Your users may want to:

As a matter of fact, being able to draw as part of an advanced search is one of the top community feature requests at Airbnb:

Original tweet link

Original tweet link

Now, implementing user-friendly map drawing capabilities is daunting but not impossible.

In this chapter youโ€™ll learn how to A) work with Google Mapsโ€™ Drawing Library and B) implement a custom, self-closing, freehand drawing tool.

Googleโ€™s Drawing Library

To use Googleโ€™s Drawing Library (i.e. the google.maps.drawing.DrawingManager class), youโ€™ll first need to load this library as part of your initialization script:

< script async defer
	src=".../maps/api/js?key=YOUR_KEY_STARTING_WITH_AIza&libraries=drawing&callback=initMap">
</script>

From there, you can create a DrawingManager instance thatโ€™ll look like this by default:

The default , , , , and  drawing modes.

The default MARKER, CIRCLE, POLYGON, POLYLINE, and RECTANGLE drawing modes.