Skip to content

Node.js module that provides a unified interface for several reverse-geocoding services.

Notifications You must be signed in to change notification settings

doublemap/reverse-geocoders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

A reverse geocoder takes a latitude and longitude coordinate and gives you the (best-guess) address of that location. This library provides easy access to multiple reverse geocoders under a unified interface. Currently supported are:

  • google - Google Maps
  • mapquestopen - MapQuest Open (requires API key)
  • mapquestnominatim - MapQuest Nominatim (default)

The library is somewhat USA-centric right now, due to our current use cases.

Interface

The reverseGeocode function takes a latitude and longitude, along with an optional service name to override which service is chosen. It returns a Q promise for the results object.

var rg = require('reverse-geocoders');
rg.reverseGeocode(42.04759, -87.67954).then(console.log);

will print:

{ street_number: '1640',
  street: 'Chicago Avenue',
  city: 'Evanston',
  state: 'Illinois',
  postal_code: '60201',
  country: 'United States of America',
  formatted_address: 'Whole Foods, 1640, Chicago Avenue, South Evanston, Evanston, Cook County, Illinois, 60201, United States of America' }

You can override the service that is called by passing in a third argument to reverseGeocode:

rg.reverseGeocode(42.04759, -87.67954, 'google').then(console.log);

Results are translated into a common format, which is an object containing the following properties:

  • street_number
  • street
  • city
  • state
  • postal_code
  • country
  • formatted_address

The result may be missing one or more of these properties if no data was found, most commonly the street number.

About

Node.js module that provides a unified interface for several reverse-geocoding services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published