How to draw polyline on google map in flutter
5,837
Use inside Google() widget polygons
and try like this
GoogleMap(
markers: markersAr,
myLocationEnabled: true,
initialCameraPosition: CameraPosition(
target: LatLng(6.843369, 79.874814),
zoom: 12.99,
),
polygons: Set<Polygon>.of(<Polygon>[
Polygon(
polygonId: PolygonId('area'),
points: getPoints(),
geodesic: true,
strokeColor: Colors.red.withOpacity(0.6),
strokeWidth: 5,
fillColor: Colors.redAccent.withOpacity(0.1),
visible: true),
]),)
put your coordinate into
getPoint()
getPoints() {
return [
LatLng(6.862472, 79.859482),
LatLng(6.862258, 79.862325),
LatLng(6.863121, 79.863644),
LatLng(6.864538, 79.865039),
LatLng(6.865124, 79.864546),
LatLng(6.866451, 79.864667),
LatLng(6.867303, 79.86544),
LatLng(6.867899, 79.865826),
LatLng(6.867867, 79.866727),
LatLng(6.864884, 79.870333),
LatLng(6.861859, 79.873112),
LatLng(6.861593, 79.87499),
LatLng(6.860837, 79.876427),
];
}
Author by
Shruti Ramnandan sharma
Updated on December 11, 2022Comments
-
Shruti Ramnandan sharma over 1 year
I'm trying to draw polyline between two location with using flutter google map library.
// here the Map Body body:Container( child: GoogleMap( myLocationEnabled: true, mapType: MapType.hybrid, onMapCreated: (GoogleMapController controller){ mapController=controller; }, initialCameraPosition: CameraPosition( target: center, zoom: 11.0 ), markers: markers, ), ),