Dammyololade / flutter_polyline_points

A flutter plugin that's decodes encoded google poly line string into list of geo-coordinates suitable for showing route/polyline on maps
MIT License
107 stars 133 forks source link

Does this package support alternate polyline? #72

Closed ziagit closed 1 year ago

ziagit commented 2 years ago

I'm using this package with Google maps in my Flutter app I can draw a route between A and B points but between A and B can be alternate paths which I need to draw them on the map, if this package support alternative routes please share a guide how to implement that.

this is my code how to add alternate routes

  _addPolyLine() {
    PolylineId id = PolylineId("poly");
    Polyline polyline = Polyline(
        polylineId: id, color: Colors.red, points: polylineCoordinates);
    polylines[id] = polyline;
    setState(() {});
  }

  _getPolyline() async {
    PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
        googleAPiKey,
        PointLatLng(_originLatitude, _originLongitude),
        PointLatLng(_destLatitude, _destLongitude),
        travelMode: TravelMode.driving,
        wayPoints: [PolylineWayPoint(location: "Sabo, Yaba Lagos Nigeria")]);
    if (result.points.isNotEmpty) {
      result.points.forEach((PointLatLng point) {
        polylineCoordinates.add(LatLng(point.latitude, point.longitude));
      });
    }
    _addPolyLine();
  }

Thanks.

Tisanthan commented 2 years ago

https://github.com/Tisanthan/flutter_polyline_points I have modifyed for alternative routes

Dammyololade commented 1 year ago

Yes it's now available on version 2.0.0