Polygon Layer
You can add areas/shapes to maps by making them out of individual coordinates using PolygonLayer
and Polygon
s.
Interactivity
PolygonLayer
s and Polygons
s support hit detection and interactivity.
Performance Optimizations
flutter_map includes many performance optimizations built in, especially as of v7. Some are enabled by default, but may be only 'weakly' applied, and others must be enabled manually. There are also some other actions that can be taken externally to improve performance
The following list is ordered from least 'intrusive'/extreme, to most intrusive. Remember to consider the potential risks of enabling an optimization before doing so.
The example application includes a stress test which loads multiple Polygon
s from a GeoJson file, with a total of 138,000 points.
Overlapping colors that are not completely opaque will not recieve the 'darkening'/layering effect - the overlapping area will just be the single colour.
On layers with (many) only small polygons (those with few points), disabling simplification may yield better performance.
Polygons may overlap after simplification when they did not before, and vice versa.
Self-intersecting (complex) Polygon
s are not supported by the triangulation algorithm, and could cause errors.
The Shamos-Hoey algorithm could be used to automatically detect self-intersections, and set the feature-level flag correspondingly. If doing this, remember that the simplification step (which runs prior to this) could either add or remove a self-intersection.
Holes are supported.
This pathway may be slower than the standard pathway, especially when used on a large scale but with simplification disabled, or used on an especially small scale.
It is intended for use when prior profiling indicates more performance is required after other methods are already in use.
Rarely, some visible artefacts may be introduced by the triangulation algorithm.
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 'poly_bool_dart'. 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).
Last updated