Skip to main content

Polygon

GmvPolygon wraps google.maps.Polygon. It imports the Google Maps maps library internally, creates the polygon on the resolved map, binds supported props and events, exposes polygonShapePromise, and removes the polygon from the map on unmount.

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

Props

PropTypeDefaultDescription
clickablebooleantrueWhether the polygon handles mouse events.
draggablebooleanfalseWhether users can drag the polygon.
editablebooleanfalseWhether users can edit the polygon paths.
fillColorstringundefinedFill color.
fillOpacitynumberundefinedFill opacity from 0 to 1.
geodesicbooleanfalseWhether polygon edges should follow geodesic segments.
pathsgoogle.maps.MVCArray<google.maps.MVCArray<google.maps.LatLng>> | google.maps.MVCArray<google.maps.LatLng> | (google.maps.LatLng | google.maps.LatLngLiteral)[] | (google.maps.LatLng | google.maps.LatLngLiteral)[][]undefinedPolygon paths.
strokeColorstringundefinedStroke color.
strokeOpacitynumberundefinedStroke opacity from 0 to 1.
strokePositiongoogle.maps.StrokePositiongoogle.maps.StrokePosition.CENTER or 0Stroke position.
strokeWeightnumberundefinedStroke width in pixels.
visiblebooleantrueWhether the polygon is visible.
zIndexnumberundefinedStacking order.
deepWatchbooleanfalseEnables deep Vue watching for the paths prop.
polygonKeystringundefinedPromise key used by usePolygonPromise(key).
mapKeystringundefinedMap promise key used when the polygon is not a direct descendant of GmvMap.
optionsRecord<string, unknown>undefinedFallback for Google Polygon options not represented by explicit props. Spread after explicit props, so it can override them.

Events

EventNotes
clickGoogle Maps event.
contextmenuGoogle Maps event.
dblclickGoogle Maps event.
dragGoogle Maps event.
dragendGoogle Maps event.
dragstartGoogle Maps event.
mousedownGoogle Maps event.
mousemoveGoogle Maps event.
mouseoutGoogle Maps event.
mouseoverGoogle Maps event.
mouseupGoogle Maps event.
paths_changedEmitted from Google Maps MVC path mutations. This is not v-model.

Exposed properties

PropertyTypeDescription
polygonShapePromisePromise<google.maps.Polygon | undefined>Resolves to the underlying Google Polygon instance.

Composable

Use usePolygonPromise(key?) from @gmap-vue/v3/composables. Without a key it uses the default polygon promise; with multiple polygons, pass the same value as polygon-key.

export function usePolygonPromise(
key: string | InjectionKey<Promise<google.maps.Polygon | undefined>> = $polygonShapePromise,
): Promise<google.maps.Polygon | undefined>;