I have implemented a screen with GoogleMaps widget and used
final Set<Polyline> _polyline = {};
List<LatLng> latlng = List();
with a sample of
latlng.add(LatLng(7.2008,79.8737));
latlng.add(LatLng(7.2018,79.8737));
latlng.add(LatLng(7.2028,79.8739));
latlng.add(LatLng(7.2028,79.8707));
latlng.add(LatLng(7.2008,79.8700));
latlng.add(LatLng(7.1998,79.8695));
but polylines draws like this
and here is the code for google map
Widget _googlemap(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
height: size.height,
width: size.width,
child: GoogleMap(
compassEnabled: true,
mapType: MapType.normal,
myLocationButtonEnabled: true,
myLocationEnabled: true,
onMapCreated: (GoogleMapController controller) async {
_controller.complete(controller);
final GoogleMapController mapController = await _controller.future;
Position position = await Geolocator()
.getLastKnownPosition(desiredAccuracy: LocationAccuracy.high);
controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
target: LatLng(position.latitude, position.longitude), zoom: 15)));
},
markers: _markers.values.toSet(),
initialCameraPosition: _initialCameraPosition,
polylines: _polyline ,
),
);
}
and I'm expecting a straight line without getting the connected end and start together. I'm glad is someone can help me out, thanks!!