UNPKG

ngx-google-place-autocomplete

Version:

* A simple and lightweight google place autocomplete directive for Angular2

2 lines 2 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ngx-google-place-autocomplete",["exports","@angular/core"],t):t(e["ngx-google-place-autocomplete"]={},e.ng.core)}(this,function(e,o){"use strict";var t=(n.decorators=[{type:o.Injectable,args:[{providedIn:"root"}]}],n.ctorParameters=function(){return[]},n.ngInjectableDef=o.defineInjectable({factory:function(){return new n},token:n,providedIn:"root"}),n);function n(){}var r=(a.prototype.ngOnInit=function(){var t=this,o=new google.maps.places.Autocomplete(this.element);google.maps.event.addListener(o,"place_changed",function(){t.zone.run(function(){var e=t.getFormattedAddress(o.getPlace());e&&t.onSelect.emit(e)})})},a.prototype.getFormattedAddress=function(e){var t={fullAddress:null,city:null,state:null,streetNumber:null,streetName:null,country:null,postalCode:null};for(var o in e.address_components){var n=e.address_components[o];t.fullAddress=e.formatted_address,-1<n.types.indexOf("locality")?t.city=n.long_name:-1<n.types.indexOf("administrative_area_level_1")?t.state=n.short_name:-1<n.types.indexOf("street_number")?t.streetNumber=n.short_name:-1<n.types.indexOf("route")?t.streetName=n.long_name:-1<n.types.indexOf("country")?t.country=n.long_name:-1<n.types.indexOf("postal_code")&&(t.postalCode=n.short_name)}return t},a.decorators=[{type:o.Directive,args:[{selector:"[ngx-google-place]"}]}],a.ctorParameters=function(){return[{type:o.ElementRef},{type:o.NgZone}]},a.propDecorators={onSelect:[{type:o.Output}]},a);function a(e,t){this.zone=t,this.onSelect=new o.EventEmitter,this.element=e.nativeElement}var l=(s.decorators=[{type:o.NgModule,args:[{declarations:[r],exports:[r]}]}],s);function s(){}e.NgxGooglePlaceAutocompleteService=t,e.NgxGooglePlaceAutocompleteDirective=r,e.NgxGooglePlaceAutocompleteModule=l,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ngx-google-place-autocomplete.umd.min.js.map