A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/maps/documentation/javascript/drawinglayer below:

Drawing Layer (Library) | Maps JavaScript API

Skip to main content Drawing Layer (Library)

Stay organized with collections Save and categorize content based on your preferences.

  1. Overview
  2. Using the Library
  3. DrawingManager Options
  4. Updating the Drawing Tools Control
  5. Drawing Events
Overview

The DrawingManager class provides a graphical interface for users to draw polygons, rectangles, polylines, circles, and markers on the map.

Using the Library

The Drawing Tools are a self-contained library, separate from the main Maps API JavaScript code. To use the functionality contained within this library, you must first load it using the libraries parameter in the Maps API bootstrap URL:

<script async
    src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async&libraries=drawing&callback=initMap">
</script>

Once you’ve added the libraries parameter, you can create a DrawingManager object as follows:

var drawingManager = new google.maps.drawing.DrawingManager();
drawingManager.setMap(map);
DrawingManager Options

The DrawingManager constructor takes a set of options that define the set of controls to display, the position of the control, and the initial drawing state.

Note: To make a shape user-editable after it has been created, set its editable property to true.

Once the DrawingManager object has been created, you can update it by calling setOptions() and passing new values.

drawingManager.setOptions({
  drawingControlOptions: {
    position: google.maps.ControlPosition.BOTTOM_LEFT,
    drawingModes: ['marker']
  }
});

To hide or show the drawing tools control:

// To hide:
drawingManager.setOptions({
  drawingControl: false
});

// To show:
drawingManager.setOptions({
  drawingControl: true
});

To remove the drawing tools control from the map object:

drawingManager.setMap(null);

Hiding the drawing control causes the drawing tools control to not display, but all of the functionality of the DrawingManager class is still available. In this way, you can implement your own control, if desired. Removing the DrawingManager from the map object disables all drawing functionality; it must be reattached to the map with drawingManager.setMap(map), or a new DrawingManager object constructed, if drawing features are to be restored.

Drawing Events

When a shape overlay is created, two events are fired:

google.maps.event.addListener(drawingManager, 'circlecomplete', function(circle) {
  var radius = circle.getRadius();
});

google.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) {
  if (event.type == 'circle') {
    var radius = event.overlay.getRadius();
  }
});

Note that google.maps.Map events, such as click and mousemove are disabled while drawing on the map.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-18 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-18 UTC."],[[["The `DrawingManager` class in the Google Maps JavaScript API enables users to draw shapes like polygons, circles, and markers directly on the map."],["To utilize the Drawing Tools, include the `libraries=drawing` parameter in the Maps API bootstrap URL when loading the API."],["Customize the drawing experience by configuring options like `drawingMode`, `drawingControl`, and shape-specific properties using the `DrawingManager` constructor and `setOptions()` method."],["Drawing events such as `{overlay}complete` and `overlaycomplete` are triggered when shapes are created, providing access to the drawn overlay for further manipulation."],["While drawing is active, standard Google Maps events like `click` and `mousemove` are temporarily disabled on the map."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4