Skip to main content

Rectangle

GmvRectangle wraps google.maps.Rectangle. It imports the Google Maps maps library internally, creates the rectangle on the resolved map, binds supported props and events, exposes rectangleShapePromise, and removes the rectangle from the map on unmount.

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

Props

PropTypeDefaultDescription
boundsgoogle.maps.LatLngBounds | google.maps.LatLngBoundsLiteralundefinedRectangle bounds.
clickablebooleantrueWhether the rectangle handles mouse events.
draggablebooleanfalseWhether users can drag the rectangle.
editablebooleanfalseWhether users can edit the rectangle bounds.
fillColorstringundefinedFill color.
fillOpacitynumberundefinedFill opacity from 0 to 1.
strokeColorstringundefinedStroke color.
strokeOpacitynumberundefinedStroke opacity from 0 to 1.
strokePositiongoogle.maps.StrokePositiongoogle.maps.StrokePosition.CENTER or 0Stroke position.
strokeWeightnumberundefinedStroke width in pixels.
visiblebooleantrueWhether the rectangle is visible.
zIndexnumberundefinedStacking order.
rectangleKeystringundefinedPromise key used by useRectanglePromise(key).
mapKeystringundefinedMap promise key used when the rectangle is not a direct descendant of GmvMap.
optionsRecord<string, unknown>undefinedFallback for Google Rectangle options not represented by explicit props. Spread after explicit props, so it can override them.

Events

Event
bounds_changed
click
contextmenu
dblclick
drag
dragend
dragstart
mousedown
mousemove
mouseout
mouseover
mouseup

Exposed properties

PropertyTypeDescription
rectangleShapePromisePromise<google.maps.Rectangle | undefined>Resolves to the underlying Google Rectangle instance.

Composable

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

export function useRectanglePromise(
key: string | InjectionKey<Promise<google.maps.Rectangle | undefined>> = $rectangleShapePromise,
): Promise<google.maps.Rectangle | undefined>;