File

src/lib/angular-google-place/services/angular-google-place.service.ts

Index

Properties
Methods

Constructor

constructor(constant: AngularGooglePlaceConstantService)
Parameters :
Name Type Optional Description
constant AngularGooglePlaceConstantService

Methods

administrative_area_level_2
administrative_area_level_2(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
administrative_area_level_3
administrative_area_level_3(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
administrative_area_level_4
administrative_area_level_4(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
administrative_area_level_5
administrative_area_level_5(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
airport
airport(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
bus_station
bus_station(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
city
city(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
colloquial_area
colloquial_area(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
country
country(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
countryIsoCode
countryIsoCode()
Returns : []
establishment
establishment(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
Private find
find(address_components: Array, query: string, val: string)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
query string
val string
Returns : any
floor
floor(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
intersection
intersection(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
natural_feature
natural_feature(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
neighborhood
neighborhood(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
park
park(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
parking
parking(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
point_of_interest
point_of_interest(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
political
political(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
post_box
post_box(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
postal_code
postal_code(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
postal_town
postal_town(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
premise
premise(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
room
room(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
state
state(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
street
street(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
street_number
street_number(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
sublocality
sublocality(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
sublocality_level_1
sublocality_level_1(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
sublocality_level_2
sublocality_level_2(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
sublocality_level_3
sublocality_level_3(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
sublocality_level_4
sublocality_level_4(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
sublocality_level_5
sublocality_level_5(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
subpremise
subpremise(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
train_station
train_station(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
transit_station
transit_station(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any
typesOptions
typesOptions()
Returns : string[]
ward
ward(address_components: Array)
Parameters :
Name Type Optional Description
address_components Array<AddressComponent>
Returns : any

Properties

Public constant
constant: AngularGooglePlaceConstantService
Type : AngularGooglePlaceConstantService
import {Injectable} from '@angular/core';
import {AddressComponent, CountryCode} from '../models/index';
import {AngularGooglePlaceConstantService} from '../constants/index';

@Injectable()
export class AngularGooglePlaceService {
  constructor(public constant: AngularGooglePlaceConstantService) {
  }


  private find(address_components: Array<AddressComponent>, query: string, val: string = null) {

    for (const attr of address_components) {
      for (const type of attr.types) {
        if (type === query) {
          return val ? (<any>attr)[val] : attr;
        }
      }
    }
    return null;
  }

  street_number(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'street_number', 'long_name');
  }

  street(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'route', 'long_name');
  }

  city(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'locality', 'long_name');
  }

  state(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'administrative_area_level_1', 'long_name');
  }

  postal_code(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'postal_code', 'long_name');
  }

  country(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'country', 'long_name');
  }

  administrative_area_level_2(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'administrative_area_level_2', 'long_name');
  }


  // MORE NOT USED YET /////
  intersection(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'intersection');
  }

  political(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'political');
  }

  administrative_area_level_3(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'administrative_area_level_3');
  }

  administrative_area_level_4(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'administrative_area_level_4');
  }

  administrative_area_level_5(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'administrative_area_level_5');
  }

  colloquial_area(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'colloquial_area');
  }

  ward(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'ward');
  }

  sublocality(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'sublocality');
  }

  sublocality_level_1(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'sublocality_level_1');
  }

  sublocality_level_2(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'sublocality_level_2');
  }

  sublocality_level_3(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'sublocality_level_3');
  }

  sublocality_level_4(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'sublocality_level_4');
  }

  sublocality_level_5(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'sublocality_level_5');
  }

  neighborhood(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'neighborhood');
  }

  premise(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'premise');
  }

  subpremise(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'subpremise');
  }

  natural_feature(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'natural_feature');
  }

  airport(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'airport');
  }

  park(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'park');
  }

  point_of_interest(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'point_of_interest');
  }

  floor(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'floor');
  }

  establishment(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'establishment');
  }

  parking(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'parking');
  }

  post_box(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'post_box');
  }

  postal_town(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'postal_town');
  }

  room(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'room');
  }

  bus_station(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'bus_station');
  }

  train_station(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'train_station');
  }

  transit_station(address_components: Array<AddressComponent>) {
    return this.find(address_components, 'transit_station');
  }

  // countryIsoCode
  countryIsoCode(): CountryCode[] {
    return this.constant.countryIsoCode();
  }

  // Types options
  typesOptions(): string[] {
    return this.constant.types_options();
  }

}

results matching ""

    No results matching ""