node-geocoder
Node library for geocoding and reverse geocoding
Currently in development
instalation
npm install node-geocoder
Geocoder Provider
google
: GoogleGeocoder support adress geocoding and reverse geocodingfreegeoip
: FreegeoipGeocoder support ip geocodingdatasciencetoolkit
: DataScienceToolkitGeocoder support ip v4 geocodingopenstreetmap
: OpenStreetMapGeocoder support adress geocoding and reverse geocoding
Http adapter
http
: This adapter use Http nodejs library (by default)requestify
: This adapter use Requestify library (you need to install requestify
)
Formatter
gpx
: format result using GPX format
Usage example
var geocoderProvider = 'google';
var httpAdapter = 'http';
var formatter = null;
var geocoder = require('node-geocoder').getGeocoder(geocoderProvider, httpAdapter, formatter);
geocoder.geocode('29 champs elysée paris', function(err, res) {
console.log(res);
});
// output :
[{
latitude: 48.8698679,
longitude: 2.3072976,
country: 'France',
countryCode: 'FR',
city: 'Paris',
zipcode: '75008',
streetName: 'Champs-Élysées',
streetNumber: '29'
}]
More
You can improve this project by adding new geocoder or http adapter
For run tests just npm test
Extending node geocoder
you can add new geocoder by implementing the two method geocode & reverse :
var geocoder = {
geocode: function(value, callback) { },
reverse: function(lat, lng, callback) { }
}
Roadmap
add results formating
more documentation
more provider