color property
The fill color of all the MapPolygon.
For setting color for each MapPolygon, please check the MapPolygon.color property.
late MapZoomPanBehavior _zoomPanBehavior;
late List<MapLatLng> _polygon;
late MapShapeSource _mapSource;
@override
void initState() {
_polygon = <MapLatLng>[
MapLatLng(38.8026, -116.4194),
MapLatLng(46.8797, -110.3626),
MapLatLng(41.8780, -93.0977),
];
_mapSource = MapShapeSource.asset(
'assets/usa.json',
shapeDataField: 'name',
);
_zoomPanBehavior = MapZoomPanBehavior();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Polygon shape')),
body: SfMaps(layers: [
MapShapeLayer(
source: _mapSource,
sublayers: [
MapPolygonLayer(
polygons: List<MapPolygon>.generate(
1,
(int index) {
return MapPolygon(
points: _polygon,
);
},
).toSet(),
color: Colors.green,
),
],
zoomPanBehavior: _zoomPanBehavior,
),
]),
);
}
Implementation
final Color? color;