Node library for geocoding and reverse geocoding
Currently in development
npm install node-geocoder
var geocoderProvider = 'google';
var httpAdapter = 'http';
// optionnal
var extra = {
apiKey: 'YOUR_API_KEY', // for map quest
formatter: null // 'gpx', 'string', ...
};
var geocoder = require('node-geocoder').getGeocoder(geocoderProvider, httpAdapter, extra);
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',
state: 'Île de France',
stateCode: 'IDF'
}]
google
: GoogleGeocoder support address geocoding and reverse geocoding, useextra.clientId
andextra.apiKey
(privateKey)for business licence, you can also useextra.language
for specify languagefreegeoip
: FreegeoipGeocoder support ip geocodingdatasciencetoolkit
: DataScienceToolkitGeocoder supports ip v4 geocoding and address geocoding, useextra.host
for specify a local instanceopenstreetmap
: OpenStreetMapGeocoder support address geocoding and reverse geocodingmapquest
: MapQuestGeocoder support address geocoding and reverse geocoding need an apiKeyagol
: ArcGis Online Geocoding service, supports geocoding and reverse. Requires a client_id & client_secret (Only works with requestify)
http
: This adapter uses Http nodejs library (by default)requestify
: This adapter uses Requestify library (you need to installrequestify
)
gpx
: format result using GPX formatstring
: format result to an String array (you need to specifyextra.formatterPattern
key)%P
country%p
country code%n
street number%S
street name%z
zip code%T
State%t
state code
You can improve this project by adding new geocoders or http adapters.
To run tests just npm test
You can add new geocoders by implementing the two method geocode & reverse:
var geocoder = {
geocode: function(value, callback) { },
reverse: function(lat, lng, callback) { }
}
- add google geocoder language option
- add openStreetmap geocoder language option
- improve http error handling
- add host options for datasciencetoolkit
- improve tests
- Added suport for the ESRI AGOL geocoding service
- Included test coverage for the new geocoder