Giter VIP home page Giter VIP logo

angular-google-place's Introduction

angular-google-place

This is a Angular-Google-Place Module publish with Angular Format Package ( ng-packgr)

NPM

devDependency Status npm npm Downloads Renovate enabled Codacy Badge

Open Source Love TypeScript license forthebadge

Docs | Demo

#Release Notes Please take care of Release Note before creating issues.

GitHub

Please feel free to declare issues or contribute : https://github.com/psykolm22/angular-google-place

Installation

๐ŸŽ’ npm package can be consumed by Angular CLI, Webpack, or SystemJS

NPM

npm install --save angular-google-place

YARN

yarn add angular-google-place --save

Don't forget to add google api in your index.html

  • in your index.html:
<script  type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&key=GOOGLE_API_KEY"></script>

Replace by our Google api key .

Usage

  • Use it in your HTML elements, for example in your ***.component.html:
<input type="text" [(ngModel)] = "address" 
 [options]='options' 
 (setAddress) = "getAddress($event)"
 (FormatAddress)="getFormattedAddress($event)"
 (street_number) = 'street_number=$event'
 (street)= 'street=$event'
 (city)= 'city=$event'
 (state)='state=$event'
 (district)='district=$event'
 (country)='country=$event'
 (postal_code)='postal_code=$event'
 (lat)='lat=$event' 
 (lng)='lng=$event' 
 (adr_address)='adr_address=$event' 
 (name)='name=$event' 
 (place_id)='place_id=$event' 
 (types)='types=$event' 
 (url)='url=$event'  
 (utc_offset)='utc_offset=$event' 
 (vicinity)='vicinity=$event' 
 (photos)='photos=$event' 
 (CountryCodes)='CountryCodes=$event'
  id="autocomplete"
 angularGooglePlace/> 
  • Add in your ***.component.ts:
  • check CHANGELOG.md , types have change to type.
import { Address } from 'angular-google-place';

 export class AppComponent {
  public options = {type : 'address', componentRestrictions: { country: 'FR' }};
  getAddress(place: Address) {
         console.log('Address', place);
     }
  getFormattedAddress(event: any) {
         console.log(event);
     }   
}
  • Add GooglePlaceModule in your ***.module.ts:
import {AngularGooglePlaceModule} from 'angular-google-place';

@NgModule({
    ...
    import: [..., AngularGooglePlaceModule]
})

#Options Options for Google Search

  • Choose one type from
  [ '(cities)',
        '(regions)',
        'country',
        'postal_code',
        'locality',
        'sublocality',
        'address',
        'geocode',
        'administrative_area_level_1',
        'administrative_area_level_2',] 
  • country ( dynamic change allow) : CountryCode ISO 3166-1 Alpha-2 ( see demo )
[options]="{
    type: 'address',
    componentRestrictions: { country: 'FR' }
    }"

#Tested in:

  • Chrome
  • Firefox
  • Safari

#For AngularJS: https://github.com/vskosp/vsGoogleAutocomplete

angular-google-place's People

Contributors

psykolm22 avatar angular-cli avatar renovate[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.