I'm building a mapping application using Flutter and the openrouteservice API to get directions between two points. I want to customize the route by avoiding certain areas or polygons defined by their coordinates. Specifically, I have a polygon defined by a set of coordinates, and I want to make sure the route doesn't pass through it.
I've successfully retrieved the route coordinates using directionsMultiRouteCoordsPost, but I'm not sure how to integrate the avoid polygons option. Here's the code I'm currently using:
final List<ORSCoordinate> routeCoordinates2 = await openrouteservice.directionsMultiRouteCoordsPost(coordinates: [
ORSCoordinate(latitude: 8.920576, longitude: 125.576619),
ORSCoordinate(
latitude: endTappedLocation!.latitude,
longitude: endTappedLocation!.longitude,
),
]);
And here are the coordinates of the polygon to avoid:
points: [
LatLng(8.923613, 125.575063),
LatLng(8.920441, 125.573503),
LatLng(8.923704, 125.567126),
LatLng(8.926735, 125.568404)
],
Can someone please help me understand how to add the avoid polygons option to my directionsMultiRouteCoordsPost function to get an alternative route that avoids the polygon? Thank you in advance."