Node Geocoder, node geocoding library, supports google maps, mapquest, open street map, tom tom, promise
npm install node-geocoder

Node library for geocoding and reverse geocoding. Can be used as a nodejs library
npm install node-geocoder
``javascript
const NodeGeocoder = require('node-geocoder');
const options = {
provider: 'google',
// Optional depending on the providers
fetch: customFetchImplementation,
apiKey: 'YOUR_API_KEY', // for Mapquest, OpenCage, APlace, Google Premier
formatter: null // 'gpx', 'string', ...
};
const geocoder = NodeGeocoder(options);
// Using callback
const res = await geocoder.geocode('29 champs elysée paris');
// output :
[
{
latitude: 48.8698679,
longitude: 2.3072976,
country: 'France',
countryCode: 'FR',
city: 'Paris',
zipcode: '75008',
streetName: 'Champs-Élysées',
streetNumber: '29',
administrativeLevels: {
level1long: 'Île-de-France',
level1short: 'IDF',
level2long: 'Paris',
level2short: '75'
},
provider: 'google'
}
];
`
`javascript
const res = await geocoder.geocode({
address: '29 champs elysée',
country: 'France',
zipcode: '75008'
});
// OpenCage advanced usage example
const res = await geocoder.geocode({
address: '29 champs elysée',
countryCode: 'fr',
minConfidence: 0.5,
limit: 5
});
// Reverse example
const res = await geocoder.reverse({ lat: 45.767, lon: 4.833 });
// Batch geocode
const results = await geocoder.batchGeocode([
'13 rue sainte catherine',
'another address'
]);
// Set specific http request headers:
const nodeFetch = require('node-fetch');
const geocoder = NodeGeocoder({
provider: 'google',
fetch: function fetch(url, options) {
return nodeFetch(url, {
...options,
headers: {
'user-agent': 'My application
'X-Specific-Header': 'Specific value'
}
});
}
});
`
- agol : ArcGis Online Geocoding service. Supports geocoding and reverse. Requires a client_id & client_secretaplace
- : APlace.io Geocoding service. Supports geocoding and reverse. Requires an access token (read about access tokens here) using options.apiKeygeocode
- For you can use simple string parameter or an object containing the different parameters (type, address, zip, city, country, countryCode and countries). See available values for type and countries parameters herereverse
- For , you can pass over {lat, lon}options.language
- For both methods, use (either fr or en) to specify the language of the resultsdatasciencetoolkit
- : DataScienceToolkitGeocoder. Supports IPv4 geocoding and address geocoding. Use options.host to specify a local instancefreegeoip
- : FreegeoipGeocoder. Supports IP geocodinggeocodio
- : Geocodio, Supports address geocoding and reverse geocoding (US only)google
- : GoogleGeocoder. Supports address geocoding and reverse geocoding. Use options.clientIdand options.apiKey(privateKey) for business licence. You can also use options.language and options.region to specify language and region, respectively.here
- : HereGeocoder. Supports address geocoding and reverse geocoding. You must specify options.apiKey with your Here API key. You can also use options.language, options.politicalView (read about political views here), options.country, and options.state.locationiq
- : LocationIQGeocoder. Supports address geocoding and reverse geocoding just like openstreetmap but does require only a locationiq api key to be set.geocode
- For you can use simple q parameter or an object containing the different parameters defined here: http://locationiq.org/#docsreverse
- For , you can pass over {lat, lon} and additional parameters defined in http://locationiq.org/#docsmapbox
- No need to specify referer or email addresses, just locationiq api key, note that there are rate limits!
- : MapBoxGeocoder. Supports address geocoding and reverse geocoding. Needs an apiKeymapquest
- : MapQuestGeocoder. Supports address geocoding and reverse geocoding. Needs an apiKeynominatimmapquest
- : Same geocoder as openstreetmap, but queries the MapQuest servers. You need to specify options.apiKeyopencage
- : OpenCage Geocoder. Aggregates many different open geocoder. Supports address and reverse geocoding with many optional parameters. You need to specify options.apiKey which can be obtained at OpenCage.opendatafrance
- : OpendataFranceGeocoder supports forward and reverse geocoding in France; for more information, see OpendataFrance API documentationopenmapquest
- : Open MapQuestGeocoder (based on OpenStreetMapGeocoder). Supports address geocoding and reverse geocoding. Needs an apiKeyopenstreetmap
- : OpenStreetMapGeocoder. Supports address geocoding and reverse geocoding. You can use options.language and options.email to specify a language and a contact email address.geocode
- For , you can use an object as value, specifying one or several parametersreverse
- For , you can use additional parametersuser-agent
- You should specify a specific or referrer header field as required by the OpenStreetMap Usage Policyoptions.osmServer
- Set to use custom nominatim server. Example: you can setup local nominatim server by following these instructions and set options.osmServer: http://localhost:8000 to use local server.pickpoint
- : PickPoint Geocoder. Supports address geocoding and reverse geocoding. You need to specify options.apiKey obtained at PickPoint.geocode
- As parameter for function you can use a string representing an address like "13 rue sainte catherine" or an object with parameters described in Forward Geocoding Reference.geocode
- For function you should use an object where {lat, lon} are required parameters. Additional parameters like zoom are available, see details in Reverse Geocoding Reference.smartyStreet
- : Smarty street geocoder (US only), you need to specify options.auth_id and options.auth_tokenteleport
- : Teleport supports city and urban area forward and reverse geocoding; for more information, see Teleport API documentationtomtom
- : TomTomGeocoder. Supports address geocoding. You need to specify options.apiKey and can use options.language to specify a languagevirtualearth
- : VirtualEarthGeocoder (Bing maps). Supports address geocoding. You need to specify options.apiKeyyandex
- : Yandex support address geocoding, you can use options.language to specify language
With the options.fetch you can provide your own method to fetch data. This method should be compatible with the Fetch API.
This allow you to specify a proxy to use, a custom timeout, specific headers, ...
- gpx : format result using GPX formatstring
- : format result to an String array (you need to specify options.formatterPattern key)%P
- country%p
- country code%n
- street number%S
- street name%z
- zip code%T
- State%t
- state code%c
- City
You can try node-geocoder here http://node-geocoder.herokuapp.com/
node-geocoder-cli You can use node-geocoder-cli to geocode in shell
You can add new geocoders by implementing the two methods geocode and reverse:
`javascript`
const geocoder = {
geocode: function(value, callback) { ... },
reverse: function(query, callback) { var lat = query.lat; var lon = query.lon; ... }
}
You can also add formatter implementing the following interface
`javascript`
const formatter = {
format: function(data) {
return formattedData;
}
};
You can improve this project by adding new geocoders.
To run tests just npm test.
To check code style just run npm run lint`.