geo-tools
v0.1.2
Published
Tools to help geocode, reverse geocode, and calculate location distances
Downloads
469
Maintainers
Readme
#geo-tools
A simple library used to geocode an address, reverse geocode coordinates, and calculate the distance between two locations. The default distance used is KM. Unit conversion methods are provided and can be seen below. The Google Maps API service is used for geocoding and reverse geocoding.
At the top of your app:
Latitude and longitude shoud be inputted as lat/lng and will be returned as lat/lng.
Returns the latitude and longitude of a given address.
Options(not required):
Takes 2 or 3 arguments. It can accept either an object with the lat/lng (ex. reverseGeocode({lat: 51.515400, lng: 7.455185}, callback)) or two numbers and the callback (ex. reverseGeocode(51.515400, 7.455185, callback)). If you use the latter format, order matters. Latitude must go first and longitude second.
Calculates the distance between two sets of coordinates. Returns the distance in Km. Accepts either 2 object arguments (ex. distance({lat: 37.79221, lng: -122.406141}, {lat: 37.774514, lng: -122.418079})), or 4 number arguments (ex. distance(37.79221, -122.406141, 37.774514, -122.418079)). If you choose the latter method, order matters and should be as follows: distance(lat1, lng1, lat2, lng2). Passing in objects is reccomended.
Converts Km into miles. The argument passed must be in Km which is the default unit used in geo-tools.
Converts Km into meters. The argument passed must be in Km which is the default unit used in geo-tools.
Converts Km into yards. The argument passed must be in Km which is the default unit used in geo-tools.
Converts Km into feet. The argument passed must be in Km which is the default unit used in geo-tools.
To run tests, type mocha into your terminal
Any and all feedback/suggestions is appreciated and should be sent to: [email protected]
Enjoy!