Code Monkey home page Code Monkey logo

node-geocoder's Introduction

node-geocoder

Build Status

Node library for geocoding and reverse geocoding

Currently in development

Installation

npm install node-geocoder

Usage example

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'
}]

Geocoder Provider

  • google : GoogleGeocoder support address geocoding and reverse geocoding, use extra.clientIdand extra.apiKey(privateKey)for business licence, you can also use extra.language for specify language
  • freegeoip : FreegeoipGeocoder support ip geocoding
  • datasciencetoolkit : DataScienceToolkitGeocoder supports ip v4 geocoding and address geocoding, use extra.host for specify a local instance
  • openstreetmap : OpenStreetMapGeocoder support address geocoding and reverse geocoding
  • mapquest : MapQuestGeocoder support address geocoding and reverse geocoding need an apiKey
  • agol : ArcGis Online Geocoding service, supports geocoding and reverse. Requires a client_id & client_secret (Only works with requestify)

Http adapter

  • http : This adapter uses Http nodejs library (by default)
  • requestify : This adapter uses Requestify library (you need to install requestify)

Formatter

  • gpx : format result using GPX format
  • string : 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 code

More

You can improve this project by adding new geocoders or http adapters.

To run tests just npm test

Extending node geocoder

You can add new geocoders by implementing the two method geocode & reverse:

var geocoder = {
    geocode: function(value, callback) { },
    reverse: function(lat, lng, callback) { }
}

Changelog

1.1.0

  • add google geocoder language option

1.2.0

  • add openStreetmap geocoder language option
  • improve http error handling

1.3.0

  • add host options for datasciencetoolkit
  • improve tests

1.4.0

  • Added suport for the ESRI AGOL geocoding service
  • Included test coverage for the new geocoder

node-geocoder's People

Contributors

aaronjudd avatar brandonaaron avatar danasf avatar nchaulet avatar rodrigok avatar timothyquach avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.