Geocoder
###Installation:
npm install geocoder
Usage
You can pass a string representation of a location and a callback function to geocoder.geocode
. It will accept anything that Google will accept: cities, streets, countries, etc.
###Example:
var geocoder = require('geocoder');
geocoder.geocode("Atlanta, GA", function ( err, data ) {
});
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
});
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
}, { sensor: true });
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
}, { language: 'de' });
geocoder.selectProvider("geonames",{"username":"demo"});
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
});
geocoder.selectProvider("yahoo",{"appid":"xxx"});
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
});
Results will look like standard Google JSON Output
You can pass in an optional options hash as a last argument, useful for setting sensor to true (it defaults to false) and the language (default is empty which means that google geocoder will guess it by geo ip data). For details see the Google Geocoding API Docs
###Testing:
nodeunit test
Roadmap
- Complete Test Suite
- Better options handling
Further Reading