arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Polygon Layer

You can add areas/shapes to maps by making them out of individual coordinates using PolygonLayer and Polygons.

An example Polygon
PolygonLayer(
  polygons: [
    Polygon(
      points: [LatLng(30, 40), LatLng(20, 50), LatLng(25, 45)],
      color: Colors.blue,
      isFilled: true,
    ),
  ],
),
circle-exclamation

Excessive use of polygons may create performance issues.

Consider enabling polygonCulling. This will prevent the calculation and rendering of polygons outside of the current viewport, however this may not work as expected in all situations.

hashtag
Polygon Manipulation

'flutter_map' doesn't provide any public methods to manipulate polygons, as these would be deemed out of scope.

However, some useful methods can be found in libraries such as 'latlong2' and . These can be applied to the input of Polygon's points argument, and the map will do it's best to try to render them. However, more complex polygons - such as those with holes - may be painted inaccurately, and may therefore require manual adjustment (of holePointsList, for example).

hashtag
onTap Support

circle-exclamation

There is no support for handling taps on polygons, due to multiple technical challenges. To stay up to date with this existing feature request, see the linked issue.

'poly_bool_dart'arrow-up-right
Polygon class - flutter_map library - Dart APIpub.devchevron-right
PolygonLayer class - flutter_map library - Dart APIpub.devchevron-right
[FEATURE] Interactive `Polygon`s · Issue #385 · fleaflet/flutter_mapGitHubchevron-right
Logo
Logo
Logo