Skip to content

Instantly share code, notes, and snippets.

@sbis04

sbis04/main.dart Secret

Created May 30, 2020 09:16
Show Gist options
  • Save sbis04/7253762591e4431c65943a08fa192c70 to your computer and use it in GitHub Desktop.
Save sbis04/7253762591e4431c65943a08fa192c70 to your computer and use it in GitHub Desktop.
double totalDistance = 0.0;
// Calculating the total distance by adding the distance
// between small segments
for (int i = 0; i < polylineCoordinates.length - 1; i++) {
totalDistance += _coordinateDistance(
polylineCoordinates[i].latitude,
polylineCoordinates[i].longitude,
polylineCoordinates[i + 1].latitude,
polylineCoordinates[i + 1].longitude,
);
}
// Storing the calculated total distance of the route
setState(() {
_placeDistance = totalDistance.toStringAsFixed(2);
print('DISTANCE: $_placeDistance km');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment