Skip to content

artsy/geoformatter

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

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published