⚠️ Early Stage Project: This library is not production-ready yet. Developers should use it with caution and expect breaking changes.

Polygon

Draw filled polygons on the map.

Installation

First, make sure you have the base map component installed:

npx shadcn@latest add https://terrae.vercel.app/maps/map.json

Then install the polygon component:

npx shadcn@latest add https://terrae.vercel.app/maps/map-polygon.json

Outline Only

Set fillOpacity=0 to create an outline-only polygon without fill.

Dashed Stroke

Use the dashArray prop to create dashed outlines. The array defines [dash length, gap length] in pixels.

Multiple Polygons

Add multiple MapPolygon components to display several polygons with different styles.

Properties

PropertyTypeDefaultDescription
coordinates[number, number][]requiredArray of [longitude, latitude] points defining the polygon
fillColorstring"#3b82f6"Fill color of the polygon
fillOpacitynumber0.4Fill opacity (0-1)
strokeColorstring"#3b82f6"Stroke/outline color
strokeWidthnumber2Stroke width in pixels
strokeOpacitynumber1Stroke opacity (0-1)
dashArray[number, number]-Dash pattern [dash, gap] for dashed strokes

Use Cases

Geofencing

Define boundaries for location-based triggers

Coverage Areas

Display service coverage or delivery zones

Property Boundaries

Show land parcels or property lines

Restricted Zones

Highlight no-fly zones or restricted areas