0.2.0 • Published 11 years ago

mapquest v0.2.0

Weekly downloads
12
License
-
Repository
github
Last release
11 years ago

mapquest

Geocode, reverse geocode, and batch geocode using MapQuests open api.

Installation via component

$ component install trevorgerhardt/mapquest

Installation via npm

$ npm install mapquest

Location Object

All functions return a location object. An example location object for the Google Headquarters is below.

{ 
  latLng: { 
    lng: -122.086672, 
    lat: 37.423581 
  },
  adminArea4: 'Santa Clara County',
  adminArea5Type: 'City',
  adminArea4Type: 'County',
  adminArea5: 'Santa Clara',
  street: '1600 Amphitheatre Parkway',
  adminArea1: 'United States of America',
  adminArea3: 'California',
  type: 's',
  displayLatLng: { 
    lng: -122.086672, 
    lat: 37.423581 
  },
  linkId: 0,
  postalCode: '94043',
  sideOfStreet: 'N',
  dragPoint: false,
  adminArea1Type: 'Country',
  geocodeQuality: 'ADDRESS',
  geocodeQualityCode: 'L1AXA',
  mapUrl: 'http://open.mapquestapi.com/staticmap/v4/getmap?type=map&size=225,160&pois=purple-1,37.423581,-122.086672,0,0|&center=37.423581,-122.086672&zoom=12&key=Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh&rand=2110607258',
  adminArea3Type: 'State' 
}

API

.geocode(address, callback)

Given an address, passes the callback a location object.

mapquest.geocode('1600 Amphitheatre Parkway, Santa Clara CA 94043', function(err, location) { console.log(location); });

.reverse(coordinates, callback)

Given a coordinates object containing latitude and longitude, passes the callback a location object.

mapquest.reverse({ latitude: 37.423581, longitude: -122.086672 }, function(err, location) { console.log(location); });

.batch(addresses, callback)

Given an array of addresse, passes the callback an array of location objects.

mapquest.batch([ '1600 Amphitheatre Parkway, Santa Clara CA 94043' ], function(err, locations) { console.log(locations); });

License

MIT