🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

google-places-address-normalizer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-places-address-normalizer

*Quick Start:*

1.0.0
npm
Version published
Weekly downloads
75
78.57%
Maintainers
1
Weekly downloads
 
Created
Source

Google Places Address Normalizer

Quick Start:

npm install google-places-address-normalizer --save

or

yarn add google-places-address-normalizer

Sample Code:

import googlePlacesNormalizer from 'google-places-address-normalizer';

let placesService = new window.google.maps.places.PlacesService(document.getElementById('placesService'));

let placesService.getDetails({
  placeId: '123' // some place_id,
}, (place, status) => {
  if (status === window.google.maps.places.PlacesServiceStatus.OK) {
    const normalizedAddress = googlePlacesNormalizer(place.address_components);
    // ... do something with normalizedAddress
  }
});

Example input:

[{
    "long_name": "916",
    "short_name": "916",
    "types": ["street_number"]
}, {
    "long_name": "Kearny Street",
    "short_name": "Kearny St",
    "types": ["route"]
}, {
    "long_name": "Financial District",
    "short_name": "Financial District",
    "types": ["neighborhood", "political"]
}, {
    "long_name": "San Francisco",
    "short_name": "SF",
    "types": ["locality", "political"]
}, {
    "long_name": "San Francisco County",
    "short_name": "San Francisco County",
    "types": ["administrative_area_level_2", "political"]
}, {
    "long_name": "California",
    "short_name": "CA",
    "types": ["administrative_area_level_1", "political"]
}, {
    "long_name": "United States",
    "short_name": "US",
    "types": ["country", "political"]
}, {
    "long_name": "94133",
    "short_name": "94133",
    "types": ["postal_code"]
}, {
    "long_name": "5107",
    "short_name": "5107",
    "types": ["postal_code_suffix"]
}]

Example output:

{
  "address": "916 Kearny Street",
  "neighborhood": "Financial District",
  "city": "San Francisco",
  "county": "San Francisco County",
  "state": "California",
  "state_abbreviation": "CA",
  "country": "United States",
  "country_abbreviation": "US",
  "postal_code": "94133",
  "postal_code_suffix": "5107"
}

License

MIT

Keywords

google

FAQs

Package last updated on 28 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts