Skip to content

A jQuery-plugin of the haversine algorithm for computing the distance between two points on a sphere. Useful for determining the distance between two lat/lon values.

Notifications You must be signed in to change notification settings

jdjkelly/jQuery-haversine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

Use Case
-------------

jQuery Haversine is useful if you need to determine the distance between two points on a map. There are lots of obvious use cases for location-based data where you need to calculate the distance between a user’s current location and a number of search results. For example, a restaurant search in a particular neighourhood.

Instructions
-------------

jQuery Haversine is called with:

$.haversine(lat1,long1,lat2,long2,unit);

This will return the distance between the two lat/long values in the specified unit. Future versions will allow you to specify a custom sphere radius (with the Earth’s radius set as a default).

You can pass the arguments as an integer (floating point included) or numeric string - the plugin uses parseFloat() to extract whatever gets passed.

Distance paramter expects "km" for kilometres, or anything else for miles.

License
-------------

Copyright 2012 Joshua Kelly

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

About

A jQuery-plugin of the haversine algorithm for computing the distance between two points on a sphere. Useful for determining the distance between two lat/lon values.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published