DrawingManager

Storybook

Open the DrawingManager story

The DrawingManager component provides Google Maps drawing controls for markers, polylines, polygons, rectangles, and circles.

The Google Maps Drawing Library is deprecated and is not available in the weekly channel (v=3.65). Use version="3.64" while that Maps JavaScript API version remains supported, or migrate drawing UI to a custom implementation.

Props

PropTypeDefaultDescription
drawingModegoogle.maps.drawing.OverlayType | nullnullActive drawing mode.
drawingControlbooleantrueShows the drawing control UI.
drawingControlOptionsgoogle.maps.drawing.DrawingControlOptionsDrawing control options.
markerOptionsgoogle.maps.MarkerOptionsOptions for drawn markers.
circleOptionsgoogle.maps.CircleOptionsOptions for drawn circles.
polygonOptionsgoogle.maps.PolygonOptionsOptions for drawn polygons.
polylineOptionsgoogle.maps.PolylineOptionsOptions for drawn polylines.
rectangleOptionsgoogle.maps.RectangleOptionsOptions for drawn rectangles.
onLoad(manager: google.maps.drawing.DrawingManager) => voidCalled after creation.
onUnmount(manager: google.maps.drawing.DrawingManager) => voidCalled before teardown.

Events

onCircleComplete, onMarkerComplete, onOverlayComplete, onPolygonComplete, onPolylineComplete, onRectangleComplete, and onDrawingModeChange map to the Google Maps drawing events.

Usage

<APIProvider apiKey="YOUR_API_KEY" libraries={['drawing']} version="3.64">
	<GoogleMap options={{ center, zoom: 12 }} mapContainerStyle="width: 100%; height: 400px;">
		<DrawingManager
			drawingControl
			onOverlayComplete={(event) => console.log(event.type, event.overlay)}
		/>
	</GoogleMap>
</APIProvider>
svelte