Skip to main content

Drawing Manager

Legacy and version-dependent

GmvDrawingManager wraps the Google Maps JavaScript API Drawing Library. Google removed DrawingManager from Maps JavaScript API v3.65+, so this component is only useful for legacy environments where Google still serves the drawing library.

For new apps, prefer editable Maps shapes, the Data layer with GeoJSON, or a third-party drawing library such as Terra Draw.

GmvDrawingManager attaches a Google google.maps.drawing.DrawingManager to a GmvMap. It imports the Google drawing library internally and rejects drawingManagerPromise with GmapVueDrawingLibraryUnavailableError when the library is unavailable.

The component is exported as DrawingManager from @gmap-vue/v3/components and registered by the plugin as GmvDrawingManager.

Props

DrawingManager props interface
export interface DrawingManagerProps {
circleOptions?: google.maps.CircleOptions;
drawingControl?: boolean;
drawingControlOptions?: google.maps.drawing.DrawingControlOptions;
drawingMode?: google.maps.drawing.OverlayType | null;
markerOptions?: google.maps.marker.AdvancedMarkerElementOptions;
polygonOptions?: google.maps.PolygonOptions;
polylineOptions?: google.maps.PolylineOptions;
rectangleOptions?: google.maps.RectangleOptions;
position?:
| 'TOP_CENTER'
| 'TOP_LEFT'
| 'TOP_RIGHT'
| 'LEFT_TOP'
| 'RIGHT_TOP'
| 'LEFT_CENTER'
| 'RIGHT_CENTER'
| 'LEFT_BOTTOM'
| 'RIGHT_BOTTOM'
| 'BOTTOM_CENTER'
| 'BOTTOM_LEFT'
| 'BOTTOM_RIGHT';
drawingModes?: google.maps.drawing.OverlayType[];
shapes?: google.maps.drawing.OverlayCompleteEvent[];
drawingKey?: string;
mapKey?: string;
options?: Record<string, unknown>;
}
PropTypeDefaultDescription
circleOptionsgoogle.maps.CircleOptionsundefinedOptions for drawn circles.
drawingControlbooleantrueShows the built-in Google drawing control. Forced to false when the component has a default slot.
drawingControlOptionsgoogle.maps.drawing.DrawingControlOptionsundefinedGoogle drawing control options.
drawingModegoogle.maps.drawing.OverlayType | nullnullCurrent drawing mode.
markerOptionsgoogle.maps.marker.AdvancedMarkerElementOptionsundefinedOptions for drawn markers according to wrapper typings. Legacy Google library behavior may differ by Maps version.
polygonOptionsgoogle.maps.PolygonOptionsundefinedOptions for drawn polygons.
polylineOptionsgoogle.maps.PolylineOptionsundefinedOptions for drawn polylines.
rectangleOptionsgoogle.maps.RectangleOptionsundefinedOptions for drawn rectangles.
positionDrawing control position stringundefinedControl position, such as TOP_CENTER or RIGHT_TOP.
drawingModesgoogle.maps.drawing.OverlayType[]undefinedToolbar drawing modes.
shapesgoogle.maps.drawing.OverlayCompleteEvent[]undefinedUser-owned tracked shapes array.
drawingKeystringundefinedPromise key used by useDrawingPromise(key).
mapKeystringundefinedMap promise key used when the component is not a direct descendant of GmvMap.
optionsRecord<string, unknown>undefinedFallback for Google DrawingManager options. Spread after explicit props, so it can override them.

The wrapper watches drawingControlOptions, position, drawingModes, and the shape option props and forwards updates with drawingManager.setOptions().

Events

EventPayloadDescription
circlecompletegoogle.maps.CircleEmitted when Google completes a circle.
markercompletegoogle.maps.marker.AdvancedMarkerElementEmitted when Google completes a marker according to wrapper typings.
polygoncompletegoogle.maps.PolygonEmitted when Google completes a polygon.
polylinecompletegoogle.maps.PolylineEmitted when Google completes a polyline.
rectanglecompletegoogle.maps.RectangleEmitted when Google completes a rectangle.
update:shapesgoogle.maps.drawing.OverlayCompleteEvent[]Emitted with a new shapes array after the wrapper appends a completed overlay. Enables v-model:shapes.
added:shapegoogle.maps.drawing.OverlayCompleteEventEmitted when the wrapper appends a completed shape.
removed:shapegoogle.maps.drawing.OverlayCompleteEventIntended to emit when the wrapper removes a tracked selected shape. Current source has edge cases; do not rely on this event as the only source of truth.

The wrapper listens to Google's overlaycomplete internally, appends the completed overlay event to shapes, emits added:shape, and emits update:shapes with the new array. The wrapper does not currently re-emit overlaycomplete as a Vue event.

Slots

When a default slot is present, the built-in drawing control is disabled. The slot receives methods for custom controls.

Slot propTypeDescription
set-drawing-mode(mode: google.maps.drawing.OverlayType | null) => voidSets the current drawing mode.
delete-selection() => voidDeletes the currently selected shape when possible. Current removal events have edge cases; keep app state defensive.

clearAll() is not a slot prop. Use a component ref for that method.

Exposed properties and methods

Exposed memberTypeDescription
drawingManagerPromisePromise<google.maps.drawing.DrawingManager | undefined>Resolves to the underlying Google DrawingManager instance, or rejects with GmapVueDrawingLibraryUnavailableError when the Drawing Library is unavailable.
setDrawingMode(mode)(mode: google.maps.drawing.OverlayType | null) => voidSets the current drawing mode.
deleteSelection()() => voidDeletes the currently selected shape when possible. Current removal events have edge cases; keep app state defensive.
clearAll()() => voidRemoves tracked shapes from the map. It does not emit a replacement shapes array.

drawingManagerInstance appears in an interface type but is not exposed by the current Vue component implementation.

<script setup lang="ts">
import { DrawingManager } from '@gmap-vue/v3/components';
import { ref } from 'vue';

const drawingRef = ref<InstanceType<typeof DrawingManager> | null>(null);

function clearShapes() {
drawingRef.value?.clearAll();
}
</script>

<template>
<GmvMap :center="{ lat: 37.7749, lng: -122.4194 }" :zoom="12" style="width: 100%; height: 500px">
<GmvDrawingManager ref="drawingRef" />
</GmvMap>

<button @click="clearShapes">Clear all</button>
</template>

Composable access

Use useDrawingPromise(key?) when direct component refs are inconvenient. Pair a custom key with the component's drawing-key prop.

import { useDrawingPromise } from '@gmap-vue/v3/composables';

const drawingManagerPromise = useDrawingPromise('legacy-drawing-manager');

For one drawing manager, the key is optional and defaults to the shared $drawingManagerPromise key. Use a unique drawingKey for every simultaneously mounted drawing manager.