Last updated:
0 purchases
haversine distance
Haversine_Distance #
A simple flutter package to calculate the distance between two coordinates
Getting Started #
The following project is a simple Dart package to calculate the distance between two points in latitude and longitude.
/// Import the package
import 'package:haversine_distance/haversine_distance.dart';
/// Create the two location objects you want to calculate the distance between.
/// The Location object is included in the package.
final startCoordinate = new Location(60.389739, 5.322323);
final endCoordinate = new Location(60.393032, 5.327248);
/// Create a new haversine object
final haversineDistance = HaversineDistance();
/// Then calculate the distance between the two location objects and set a unit.
/// You can select between KM/MILES/METERS/NMI
haversineDistance.haversine(startCoordinate, endCoordinate, Unit.KM).floor();
copied to clipboard
API #
Units to calculate #
KM, Meters, Miles, NMI,
enum Unit { KM, MILE, METER, NMI }
copied to clipboard
Location Class: #
Class Location(){
String latitude;
String longitude;
}
copied to clipboard
Thanks #
The following Dart package is highly inspired by the following npm project: https://www.npmjs.com/package/haversine
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.