Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-haversine

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-haversine

ng-haversine is an AngularJS module that applies the Haversine formula to a pair of coordinates to calculate the distance between them.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

ng-haversine

ng-haversine is an AngularJS module that applies the Haversine formula to a pair of coordinates to calculate the distance between them.

How to

The first step is to download the ng-haversine script. You can do it cloning this repo:

$ git clone https://github.com/vermicida/ng-haversine.git

Or via NPM:

$ npm install ng-haversine

Once the library is downloaded, make sure you are referencing it in your index.html, just after the AngularJS library reference:

<script src="./node_modules/ng-haversine/ng-haversine.min.js"></script>

You must inject the ng-haversine dependency within your module setter:

angular.module("test", ["dahr.ng-haversine"]);

Now, you are ready to go. You will need two coordinates given in the format below:

var coord1 = {
  "latitude": 40.4169473,
  "longitude": -3.7057172
};

var coord2 = {
  "latitude": 40.4236942,
  "longitude": -3.7109793
};

To calculate the distance between them, you must use the function distance() from the service $haversine:

var distance = $haversine.distance(coord1, coord2);

IMPORTANT: The distance is given in meters.

License

Code released under the MIT license.

Keywords

FAQs

Package last updated on 30 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc