Skip to content

ClearBlade/google-maps-reverse-geocode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipm package: google-maps-reverse-geocode

Overview

Reverse geocoding of coordinates to addresses.

This is an ipm package, which contains one or more reusable assets within the ipm Community. The 'package.json' in this repo is a ipm spec's package.json, here, which is a superset of npm's package.json spec, here.

Browse ipm Packages

Setup

API key is needed to use this ipm-package which can be generated by following instructions at Google API Console documentation.

Usage

The street address can be fetched by giving lat, long co-ordinates. This package can be easily added to your existing system.

Assets

Code Services

Example

RevGeoExample - Given lat long coordinates, find the street address.

Code Libraries

ReverseGeocoding - This library lets user to fetch street address given lat, longs. It can be accessed by creating an object of ReverseGeocoding and calling the execute method.

API

Typedefs

callback : function

This callback is displayed as part of ReverseGeocoding.

ReverseGeocoding : Object

Reverse Geocoding object requires an API Key

callback : function

This callback is displayed as part of ReverseGeocoding.

Kind: global typedef

Param Type
err Object
resp Object

ReverseGeocoding : Object

Reverse Geocoding object requires an API Key

Kind: global typedef

Param Type Description
key string API Key for Google Geocoding Service, https://developers.google.com/maps/documentation/javascript/get-api-key

ReverseGeocoding.execute ⇒ Object

This method processes lat, long and returns array of addresses. Detailed information can be found at https://developers.google.com/maps/documentation/javascript/RevGeoExamples/geocoding-reverse

Kind: static typedef of ReverseGeocoding
Returns: Object - response, as specified in Google Maps api, example response shown

Param Type Description
lat number Latitude of point of interest, ex. 30.2672
long number Longitude of point of interest, ex -97.7431
callback callback signature function(err, data){}

Example

var rg = ReverseGeocoding(key);
rg.execute(lat, long, function(err, data){
     if(err){
         resp.error(data);
     }
     resp.success(data.formatted_address);
});

/* Example response
 {
  "address_components": [
    {
      "long_name": "501",
      "short_name": "501",
      "types": [
        "street_number"
      ]
    },
    {
      "long_name": "Congress Avenue",
      "short_name": "Congress Ave",
      "types": [
        "route"
      ]
    },
    {
      "long_name": "Downtown",
      "short_name": "Downtown",
      "types": [
        "neighborhood",
        "political"
      ]
    },
    {
      "long_name": "Austin",
      "short_name": "Austin",
      "types": [
        "locality",
        "political"
      ]
    },
    {
      "long_name": "Travis County",
      "short_name": "Travis County",
      "types": [
        "administrative_area_level_2",
        "political"
      ]
    },
    {
      "long_name": "Texas",
      "short_name": "TX",
      "types": [
        "administrative_area_level_1",
        "political"
      ]
    },
    {
      "long_name": "United States",
      "short_name": "US",
      "types": [
        "country",
        "political"
      ]
    },
    {
      "long_name": "78701",
      "short_name": "78701",
      "types": [
        "postal_code"
      ]
    }
  ],
  "formatted_address": "501 Congress Ave, Austin, TX 78701, USA",
  "geometry": {
    "bounds": {
      "northeast": {
        "lat": 30.268066,
        "lng": -97.742813
      },
      "southwest": {
        "lat": 30.2671174,
        "lng": -97.74313049999999
      }
    },
    "location": {
      "lat": 30.2671158,
      "lng": -97.7427629
    },
    "location_type": "RANGE_INTERPOLATED",
    "viewport": {
      "northeast": {
        "lat": 30.2689406802915,
        "lng": -97.7416227697085
      },
      "southwest": {
        "lat": 30.2662427197085,
        "lng": -97.7443207302915
      }
    }
  },
  "place_id": "Eic1MDEgQ29uZ3Jlc3MgQXZlLCBBdXN0aW4sIFRYIDc4NzAxLCBVU0E",
  "types": [
    "street_address"
}
  ]
*/

About

Reverse geocoding of coordinates to addresses

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%