Skip to content

Polygon (gm-polygon)


In addition to rectangles, polylines, and circles you can also create polygons on a map.

Simple Use (demo)

html
<template>
  <div style="height: 500px">
    <gm-map>
      <gm-polygon :paths="[{ lat: -28, lng: 125 }, { lat: -25, lng: 130 }, { lat: -32, lng: 120 }]" />
    </gm-map>
  </div>
</template>

<script setup lang="ts">
import { gmMap, gmPolygon } from 'v3-gmaps';
</script>

Props

PropsTypeDefaultDescription
draggablebooleanfalseWhether this Polygon can be dragged over the map.
editablebooleanfalseWhether this Polygon can be edited by dragging the control points shown at the vertices and on each edge.
pathsGmPosition[] | GmPosition[][]-The ordered sequence of coordinates that designates a closed loop.
visiblebooleantrueWhether this Polygon is visible on the map.
optionsgoogle.maps.PolygonOptions-Google Maps PolygonOptions interface

Events

EventTypeDescription
clickGmPositionThis event is fired when the DOM click event is fired on the Polygon.
contextmenuGmPositionThis event is fired when the DOM contextmenu event is fired on the Polygon.
dblclickGmPositionThis event is fired when the DOM dblclick event is fired on the Polygon.
dragGmPositionThis event is repeatedly fired while the user drags the Polygon.
dragendGmPositionThis event is fired when the user stops dragging the Polygon.
dragstartGmPositionThis event is fired when the user starts dragging the Polygon.
mountedgoogle.maps.PolygonOn mounted the component will emit the Google Maps object it represents.
mousedownGmPositionThis event is fired for a mousedown on the Polygon.
mousemoveGmPositionThis event is fired for a mousemove on the Polygon.
mouseoutGmPositionThis event is fired for a mouseout on the Polygon.
mouseoverGmPositionThis event is fired for a mouseover on the Polygon.
mouseupGmPositionThis event is fired for a mouseup on the Polygon.
paths_changedGmPosition[] | GmPosition[][]This event is fired when any of the Polygon's paths are changed.
rightclickGmPositionThis event is fired for a rightclick on the Polygon.
unmountedgoogle.maps.PolygonOn unmounted the component will emit the Google Maps object it represents.

Notes

  • Unlike polylines, a polygon may consist of one or more paths. As a result, the paths property may specify one or more arrays of LatLng (GmPosition) coordinates.
  • If you define the coordinates clockwise, the polygon will be shaded in. If you define the coordinates anti-clockwise, the polygon will remove shading.

Released under the MIT License.