###Installation:
npm install geocoder
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');
// Geocoding
geocoder.geocode("Atlanta, GA", function ( err, data ) {
// do something with data
});
// Reverse Geocoding
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
// do something with data
});
// Setting sensor to true
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
// do something with data
}, { sensor: true });
// Setting language to German
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
// do something with data
}, { language: 'de' });
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
- Complete Test Suite
- Better options handling