Drawing Library

DrawingManager class

google.maps.drawing.DrawingManager class

Allows users to draw markers, polygons, polylines, rectangles, and circles on the map. TheDrawingManager's drawing mode defines the type of overlay that will be created by the user. Adds a control to the map, allowing the user to switch drawing mode.

This class extends MVCObject.

Access by callingconst {DrawingManager} = await google.maps.importLibrary( "drawing" ).SeeLibraries in the Maps JavaScript API.

DrawingManager
DrawingManager([options])
Parameters:
Creates aDrawingManagerthat allows users to draw overlays on the map, and switch between the type of overlay to be drawn with a drawing control.
getDrawingMode
getDrawingMode()
Parameters:None
Return Value:OverlayType|null
Returns theDrawingManager's drawing mode.
getMap
getMap()
Parameters:None
Return Value:Map
Returns theMapto which theDrawingManageris attached, which is theMapon which the overlays created will be placed.
setDrawingMode
setDrawingMode(drawingMode)
Parameters:
Return Value:None
Changes theDrawingManager's drawing mode, which defines the type of overlay to be added on the map. Accepted values are'marker','polygon','polyline','rectangle','circle',ornull.A drawing mode ofnullmeans that the user can interact with the map as normal, and clicks do not draw anything.
setMap
setMap(map)
Parameters:
Return Value:None
Attaches theDrawingManagerobject to the specifiedMap.
setOptions
setOptions(options)
Parameters:
Return Value:None
Sets theDrawingManager's options.
Inherited: addListener, bindTo, get, notify, set, setValues, unbind, unbindAll
circlecomplete
function(circle)
Arguments:
  • circle:CircleThe circle that the user has just drawn.
This event is fired when the user has finished drawing a circle.
markercomplete
function(marker)
Arguments:
  • marker:MarkerThe marker that the user has just drawn.
This event is fired when the user has finished drawing a marker.
overlaycomplete
function(event)
Arguments:
  • event:OverlayCompleteEventThe overlay that the user has just drawn, together with the type of the overlay.
This event is fired when the user has finished drawing an overlay of any type.
polygoncomplete
function(polygon)
Arguments:
  • polygon:PolygonThe polygon that the user has just drawn.
This event is fired when the user has finished drawing a polygon.
polylinecomplete
function(polyline)
Arguments:
  • polyline:PolylineThe polyline that the user has just drawn.
This event is fired when the user has finished drawing a polyline.
rectanglecomplete
function(rectangle)
Arguments:
  • rectangle:RectangleThe rectangle that the user has just drawn.
This event is fired when the user has finished drawing a rectangle.

DrawingManagerOptions interface

google.maps.drawing.DrawingManagerOptions interface

Options for the drawing manager.

circleOptionsoptional
Type:CircleOptionsoptional
Options to apply to any new circles created with thisDrawingManager.Thecenterandradiusproperties are ignored, and themapproperty of a new circle is always set to theDrawingManager's map.
drawingControloptional
Type:booleanoptional
Default:true
The enabled/disabled state of the drawing control.
drawingControlOptionsoptional
The display options for the drawing control.
drawingModeoptional
Type:OverlayTypeoptional
TheDrawingManager's drawing mode, which defines the type of overlay to be added on the map. Accepted values are'marker','polygon','polyline','rectangle','circle',ornull.A drawing mode ofnullmeans that the user can interact with the map as normal, and clicks do not draw anything.
mapoptional
Type:Mapoptional
TheMapto which theDrawingManageris attached, which is theMapon which the overlays created will be placed.
markerOptionsoptional
Type:MarkerOptionsoptional
Options to apply to any new markers created with thisDrawingManager.Thepositionproperty is ignored, and themapproperty of a new marker is always set to theDrawingManager's map.
polygonOptionsoptional
Type:PolygonOptionsoptional
Options to apply to any new polygons created with thisDrawingManager.Thepathsproperty is ignored, and themapproperty of a new polygon is always set to theDrawingManager's map.
polylineOptionsoptional
Type:PolylineOptionsoptional
Options to apply to any new polylines created with thisDrawingManager.Thepathproperty is ignored, and themapproperty of a new polyline is always set to theDrawingManager's map.
rectangleOptionsoptional
Type:RectangleOptionsoptional
Options to apply to any new rectangles created with thisDrawingManager.Theboundsproperty is ignored, and themapproperty of a new rectangle is always set to theDrawingManager's map.

DrawingControlOptions interface

google.maps.drawing.DrawingControlOptions interface

Options for the rendering of the drawing control.

drawingModesoptional
Type:Array<OverlayType>optional
The drawing modes to display in the drawing control, in the order in which they are to be displayed. The hand icon (which corresponds to thenulldrawing mode) is always available and is not to be specified in this array.
positionoptional
Type:ControlPositionoptional
Position id. Used to specify the position of the control on the map.

OverlayCompleteEvent interface

google.maps.drawing.OverlayCompleteEvent interface

The properties of an overlaycomplete event on aDrawingManager.

overlay
The completed overlay.
type
The completed overlay's type.

OverlayType constants

google.maps.drawing.OverlayType constants

The types of overlay that may be created by theDrawingManager.Specify these by value, or by using the constant's name. For example,'polygon'orgoogle.maps.drawing.OverlayType.POLYGON.

Access by callingconst {OverlayType} = await google.maps.importLibrary( "drawing" ).SeeLibraries in the Maps JavaScript API.

CIRCLE Specifies that theDrawingManagercreates circles, and that the overlay given in theoverlaycompleteevent is a circle.
MARKER Specifies that theDrawingManagercreates markers, and that the overlay given in theoverlaycompleteevent is a marker.
POLYGON Specifies that theDrawingManagercreates polygons, and that the overlay given in theoverlaycompleteevent is a polygon.
POLYLINE Specifies that theDrawingManagercreates polylines, and that the overlay given in theoverlaycompleteevent is a polyline.
RECTANGLE Specifies that theDrawingManagercreates rectangles, and that the overlay given in theoverlaycompleteevent is a rectangle.