Skip to main content
layers

Polygon Layer

PolygonLayer fills and outlines areas. Polygon keeps flutter_map's fields — points, holePointsList, color, borderColor, borderStrokeWidth — drawn natively on Google Maps and MapKit, by flutter_map elsewhere.

PolygonLayer(
  polygons: [
    Polygon(points: countryBorder, color: Color(0x66009688), borderStrokeWidth: 2),
  ],
)

The demo outlines every European country, shows the tapped one's name, and highlights it on tap:

Apple MapKit (iOS)Google Maps (Android)
The countries of Europe outlined, Poland highlightedThe countries of Europe outlined on Google Maps

Holes and taps​

  • Holes (holePointsList) are supported.
  • A tap is resolved in Dart through the layer's hit tester — pass a hitNotifier to PolygonLayer and read the tapped polygon in MapOptions.onTap.

Stroke style​

pattern, strokeCap and strokeJoin reach both native maps:

Android (Google Maps)iOS, macOS (MapKit)
patternstrokePattern, in physical pixelslineDashPattern, compensated for the cap added to each dash
strokeJoinstrokeJointTypelineJoin, with Flutter's miter limit of 4
strokeCapdash ends drawn by the platformlineCap at the dash ends

A cap only ever shows at the ends of dashes, since a polygon's outline is closed: on a solid outline strokeCap changes nothing. disableHolesBorder is drawn by composition natively — the polygon without its stroke, plus its outer ring as a line.