Skip to content

Polygon

<Polygon /> component represents an area enclosed by a closed path (or loop), which is defined by a series of coordinates. for more detail, see official documentation.

Basic Example

const triangleCoords = [
{ lat: 25.774, lng: -80.19 },
{ lat: 18.466, lng: -66.118 },
{ lat: 32.321, lng: -64.757 },
];
function MyMap() {
return (
<GoogleMap
className='h-[400px]'
initialZoom={5}
initialCenter={{ lat: 24.886, lng: -70.268 }}
mapOptions={{
mapTypeId: "terrain",
}}
>
<Polygon
paths={triangleCoords}
strokeColor="#FF0000"
strokeOpacity={0.8}
strokeWeight={2}
fillColor="#FF0000"
fillOpacity={0.35}
/>
</GoogleMap>
);
}

Props

PropsTypeDescription
pathsgoogle.maps.MVCArray<google.maps.MVCArray<LatLng>> | google.maps.MVCArray<LatLng> | Array<Array<LatLng | LatLngLiteral>> | Array<LatLng | LatLngLiteral>The ordered sequence of coordinates for drawing Polygon. Paths are closed automatically; do not repeat the first vertex of the path as the last vertex.
clickablebooleanIndicates whether this Polygon handles mouse events.
draggablebooleanif flag is set to true, the user can drag Polygon over the map.
editablebooleanif flag is set to true, the user can edit Polygon by dragging the control points shown at the vertices and on each segment.
fillColorstringThe fill color. All CSS3 colors are supported except for extended named colors.
fillOpacitynumberThe fill opacity between 0.0 and 1.0
geodesicbooleanif flag is set to true, edges of the polygon are interpreted as geodesic and will follow the curvature of the Earth.
strokeColorstringThe stroke color. All CSS3 colors are supported except for extended named colors.
strokeOpacitynumberThe stroke opacity between 0.0 and 1.0.
strokePositiongoogle.maps.StrokePositionThe stroke position.
strokeWeightnumberThe stroke width in pixels.
visiblebooleanWhether this polygon is visible on the map.
zIndexnumberzIndex for Polygon
onClick(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for click event. Please refer to the official documentation.
onContextmenu(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for contextmenu event. Please refer to the official documentation.
onDblClick(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for dblclick event. Please refer to the official documentation.
onDrag(polygon: google.maps.Polygon, event: google.maps.MapMouseEvent) => void;callback for drag event. Please refer to the official documentation.
onDragEnd(polygon: google.maps.Polygon, event: google.maps.MapMouseEvent) => void;callback for dragend event. Please refer to the official documentation.
onDragStart(polygon: google.maps.Polygon, event: google.maps.MapMouseEvent) => void;callback for dragstart event. Please refer to the official documentation.
onMouseDown(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for mousedown event. Please refer to the official documentation.
onMouseMove(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for mousemove event. Please refer to the official documentation.
onMouseOut(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for mouseout event. Please refer to the official documentation.
onMouseOver(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for mouseover event. Please refer to the official documentation.
onMouseUp(polygon: google.maps.Polygon, event: google.maps.PolyMouseEvent) => void;callback for mouseup event. Please refer to the official documentation.