Node Geocoder, node geocoding library, supports google maps, mapquest, open street map, tom tom, promise

Node library for geocoding and reverse geocoding. Can be used as a nodejs library
npm install node-geocoder
var geocoderProvider = 'google';var httpAdapter = 'http';// optionnal var extra = apiKey: 'YOUR_API_KEY' // for Mapquest, OpenCage, Google Premier formatter: null // 'gpx', 'string', ... ; var geocoder = require'node-geocoder'geocoderProvider httpAdapter extra; // Using callback geocodergeocode'29 champs elysée paris' console.logres;; // Or using Promise geocodergeocode'29 champs elysée paris' then console.logres; catch console.logerr; ; // 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' ## Advanced usage only google and here providersgeocodergeocodeaddress: '29 champs elysée' country: 'France' zipcode: '75008' console.logres;; // Reverse example // Using callback geocoderreverselat:45.767 lon:4.833 console.logres;; // Or using Promise geocoderreverselat:45.767 lon:4.833 then console.logres; catch console.logerr; ; // Batch geocode geocoderbatchGeocode'13 rue sainte catherine' 'another adress' // Return an array of type {error: false, value: []} console.logresults ;; // Set specific http request headers: var HttpsAdapter = require'node-geocoder/lib/httpadapter/httpsadapter.js'var httpAdapter = null headers: 'user-agent': 'My application <email@domain.com>' 'X-Specific-Header': 'Specific value' var geocoder = require'node-geocoder'geocoderProvider httpAdapter extra;
google : GoogleGeocoder. Supports address geocoding and reverse geocoding. Use extra.clientIdand extra.apiKey(privateKey) for business licence. You can also use extra.language and extra.region to specify language and region, respectively. Note that 'https' is required when using an apiKeyhere : HereGeocoder. Supports address geocoding and reverse geocoding. You must specify extra.appId and extra.appCode with your license keys. You can also use extra.language, extra.politicalView (read about political views here), extra.country, and extra.state.freegeoip : FreegeoipGeocoder. Supports IP geocodingdatasciencetoolkit : DataScienceToolkitGeocoder. Supports IPv4 geocoding and address geocoding. Use extra.host to specify a local instanceopenstreetmap : OpenStreetMapGeocoder. Supports address geocoding and reverse geocoding. You can use extra.language and extra.email to specify a language and a contact email address.
geocode, you can use an object as value, specifying one or several parameters from https://wiki.openstreetmap.org/wiki/Nominatim#Parametersreverse, you can use additional parameters from https://wiki.openstreetmap.org/wiki/Nominatim#Parameters_2user-agent or referrer header field as required by
https://wiki.openstreetmap.org/wiki/Nominatim_usage_policymapquest : MapQuestGeocoder. Supports address geocoding and reverse geocoding. Needs an apiKeyopenmapquest : Open MapQuestGeocoder (based on OpenStreetMapGeocoder). Supports address geocoding and reverse geocoding. Needs an apiKeyagol : ArcGis Online Geocoding service. Supports geocoding and reverse. Requires a client_id & client_secret and 'https' http adaptertomtom: TomTomGeocoder. Supports address geocoding. You need to specify extra.apiKeynominatimmapquest: Same geocoder as openstreetmap, but queries the MapQuest servers. You need to specify extra.apiKeyopencage: OpenCage Geocoder. Uses multiple open sources. Supports address and reverse geocoding. You need to specify extra.apiKeysmartyStreet: Smarty street geocoder (US only), you need to specify extra.auth_id and extra.auth_tokengeocodio: Geocodio, Supports address geocoding and reverse geocoding (US only)yandex: Yandex support address geocoding, you can use extra.language to specify languageteleport: Teleport supports city and urban area forward and reverse geocoding; for more information, see Teleport API documentationhttps: This adapter uses the Https nodejs library (default)http: This adapter uses the Http nodejs librarygpx : format result using GPX formatstring : format result to an String array (you need to specify extra.formatterPattern key)
%P country%p country code%n street number%S street name%z zip code%T State%t state codenode-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:
var geocoder = var lat = querylat; var lon = querylon;
You can also add formatter implementing the following interface
var formatter = return formattedData;
You can improve this project by adding new geocoders or http adapters.
To run tests just npm test.
To check code style install jshint and just run jshint lib test.