drawPoly method
Implementation
drawPoly(GeoCodingResponse pickup, GeoCodingResponse dropoff) async {
pickupLocation = pickup;
isLoading = true;
notifyListeners();
getAvailableDrivers();
markerList = [];
markerList.add(MarkerRF(
Id: "001",
Positions: CoordinateRF(
double.parse(pickup.lat),
double.parse(pickup.lng),
),
Image: LibsRF.instance.Configuration.Engine.MarkersList[1].Image,
alignment: Alignment.topCenter));
markerList.add(MarkerRF(
Id: "002",
Positions: CoordinateRF(
double.parse(dropoff.lat),
double.parse(dropoff.lng),
),
Image: LibsRF.instance.Configuration.Engine.MarkersList[0].Image,
alignment: Alignment.topCenter));
try {
Response response = await getPolyline(pickup, dropoff);
if (response.body != null) {
RouteResponse routeResponse =
RouteResponse.fromJson(json.decode(response.body));
for (var element in routeResponse.features[0].geometry.coordinates) {
points.add(CoordinateRF(element[1], element[0]));
}
}
} catch (e) {
errorMessage = e.toString();
} finally {
isLoading = false;
notifyListeners();
}
}