Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.
/ geo_formatter Public archive

A JS wrapper for easier-to-work-with Google Geocoder results.

License

Notifications You must be signed in to change notification settings

afeld/geo_formatter

Repository files navigation

GeoFormatter Build Status

When interacting with Google Maps via JavaScript, the result objects that are returned are tough to work with. GeoFormatter is a JS port of the geocoder Ruby gem's Google result converter, which wraps a GeocoderResult from Google Maps API v3 object to provide convenience methods. Basic usage:

// boilerplate geocoding
geocoder.geocode({ 'address': address }, function(results, status){
  if (status === google.maps.GeocoderStatus.OK){

    // wrap a result
    var geo = new GeoFormatter(results[0]);

    // use the convenience methods
    console.log('city:' + geo.getCity() );
    console.log('state:' + geo.getState() );

  }
});

Supports AMD, CommonJS, and as a GeoFormatter browser global.

API Docs

Constructor

Takes a google.maps.GeocoderResult

Methods

  • getCoordinates()
  • getAddress()
  • getNeighborhood()
  • getCity()
  • getState()
  • getStateCode()
  • getSubState()
  • getSubStateCode()
  • getCountry()
  • getCountryCode()
  • getPostalCode()
  • getRoute()
  • getStreetNumber()
  • getStreetAddress()
  • getTypes()
  • getFormattedAddress()
  • getGeometry()
  • getPrecision()

Running Tests

npm install
bundle install

npm test

About

A JS wrapper for easier-to-work-with Google Geocoder results.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published