Skip to content

A simple flutter package to calculate the distance between two coordinates

License

Notifications You must be signed in to change notification settings

ertkjern/flutter_haversine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pub package

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();

API

Units to calculate

KM, Meters, Miles, NMI,

enum Unit { KM, MILE, METER, NMI }

Location Class:

Class Location(){
 String latitude;
 String longitude;
}

Thanks

The following Dart package is highly inspired by the following npm project: https://www.npmjs.com/package/haversine

About

A simple flutter package to calculate the distance between two coordinates

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages