addPolylinesBetweenMarkers method

void addPolylinesBetweenMarkers()

addPolylinesBetweenMarkers method adds polylines between the markers on the map. It takes no parameters and adds polylines between the markers on the map.

Implementation

void addPolylinesBetweenMarkers() {
  List<Marker> markers = _markers.toList();
  if (markers.length < 2) return;

  _polylines.clear();

  for (int i = 0; i < markers.length - 1; i++) {
    LatLng start = markers[i].position;
    LatLng end = markers[i + 1].position;

    List<LatLng> polylineCoordinates = [start, end];

    PolylineId id = PolylineId("poly_${i}_${i + 1}");
    _polylines.add(Polyline(
      polylineId: id,
      color: LgAppColors.lgColor2,
      points: polylineCoordinates,
      width: 4,
      visible: true,
    ));
  }

  notifyListeners();
}