How to Add Google Locations Autocomplete to your Angular Application ? Last Updated : 15 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report The task here is to Add Google Locations Autocomplete to your Angular Application. When user will enter some text for a location in the Textfield, he/she will get locations recommendations and can autocomplete the location. For achieving the target, we will use ngx-google-places-autocomplete angular package. What is ngx-google-places-autocomplete ? This module is a wrapper for Google Places Autocomplete js library. It allows us to integrate locations autocomplete to our project. ApproachFirst install ngx-google-places-autocomplete to your angular project> For npm: npm install ngx-google-places-autocomplete For yarn: yarn add ngx-google-places-autocompleteAdd library to your index.html in src of your project app. <script src="https://maps.googleapis.com/maps/api/js?key=<Your API KEY>&libraries=places&language=en"></script> Generate an API Key and place that API Key in above script tag in place of <Your API KEY>. To Generate an API key follow the below steps: Go to https://developers.google.com/maps/documentation/places/web-service/get-api-key and follow all the steps to create an API key. Enable Places API for your API Key.Make sure your API is enabled, to enable your API follow the steps from this link https://support.google.com/googleapi/answer/6158841?hl=en. Do necessary imports of GooglePlaceModule in app.module.ts. import { GooglePlaceModule } from "ngx-google-places-autocomplete"; @NgModule({ imports: [ GooglePlaceModule ], In HTML file for appcomponent. Define code for input field, in that input field user defined function AddressChange() will be called by (onAddressChange) passing $event and options will take care of country set in country array of component.ts file.In component.ts file , user defined function take formatted_address from $event address which is then used to set address in input field by interpolation binding. Note: In country Array there is "AU" added for Australia, you can add any other country according to you. Implementation: app.module.ts JavaScript import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; import '@angular/compiler'; //import for GooglePlaceModule import { GooglePlaceModule } from "ngx-google-places-autocomplete"; @NgModule({ declarations: [ AppComponent, ], imports: [ BrowserModule, //Adding to imports GooglePlaceModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } app.component.html HTML <div class="container"> <h1>GeeksforGeeks</h1> <h2>Google Places Autocomplete</h2> <input ngx-google-places-autocomplete [options]= 'options' (onAddressChange)="AddressChange($event)"/> {{ formattedaddress }} </div> app.component.ts JavaScript import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'rou'; //Local Variable defined formattedaddress=" "; options={ componentRestrictions:{ country:["AU"] } } public AddressChange(address: any) { //setting address from API to local variable this.formattedaddress=address.formatted_address } } Output: Run development server using ng serve and write some location to input field to see Autocomplete locations. Create Quiz Comment T taran910 Follow 1 Improve T taran910 Follow 1 Improve Article Tags : AngularJS AngularJS-Misc Explore AngularJS BasicsAngularJS Tutorial 5 min read Introduction to AngularJS 4 min read Angular CLI | Angular Project Setup 3 min read AngularJS Expressions 2 min read AngularJS Modules 3 min read AngularJS ng-model Directive 4 min read AngularJS Data Binding 4 min read AngularJS Controllers 3 min read AngularJS | Scope 2 min read AngularJS Services 4 min read AngularJS | AJAX - $http 3 min read AngularJS | Tables 2 min read AngularJS Select Boxes 2 min read AngularJS SQL 3 min read AngularJS HTML DOM 2 min read AngularJS Events 3 min read AngularJS | Forms 3 min read AngularJS Form Validation 3 min read AngularJS | API 2 min read AngularJS and W3.CSS 2 min read AngularJS Includes 3 min read AngularJS Animations 1 min read AngularJS | Application 3 min read AngularJS DirectivesAngularJS Directives 9 min read AngularJS ng-app Directive 1 min read AngularJS ng-bind Directive 2 min read AngularJS ng-bind-html Directive 2 min read AngularJS ng-bind-template Directive 2 min read AngularJS ng-blur Directive 1 min read AngularJS ng-change Directive 2 min read AngularJS ng-checked Directive 2 min read AngularJS ng-class Directive 2 min read AngularJS ng-class-even Directive 2 min read AngularJS ng-class-odd Directive 2 min read AngularJS ng-click Directive 2 min read AngularJS ng-cloak Directive 2 min read AngularJS ng-controller Directive 2 min read AngularJS Directives Complete Reference 2 min read AngularJS FiltersAngularJS | Filters 7 min read AngularJS currency Filter 2 min read AngularJS | date Filter 2 min read AngularJS filter Filter 3 min read AngularJS json Filter 2 min read AngularJS limitTo Filter 2 min read AngularJS lowercase Filter 1 min read AngularJS number Filter 1 min read AngularJS orderBy Filter 4 min read AngularJs uppercase Filter 1 min read AngularJS Converting FunctionsAngularJS angular.lowercase() Function 2 min read AngularJS angular.uppercase() Function 1 min read AngularJS angular.forEach() Function 1 min read AngularJS Comparing FunctionsAngularJS angular.isArray() Function 2 min read AngularJS angular.isDate() Function 2 min read AngularJS angular.isDefined() Function 2 min read AngularJS angular.isElement() Function 2 min read AngularJS angular.isFunction() Function 2 min read AngularJS angular.isNumber() Function 2 min read AngularJS angular.isObject() Function 2 min read AngularJS | angular.isString() Function 1 min read AngularJS angular.isUndefined() Function 2 min read AngularJS angular.equals() Function 2 min read AngularJS angular.toJson() Function 2 min read AngularJS QuestionsHow to bundle an Angular app for production? 4 min read How to add many functions in one ng-click directive? 2 min read How to directly update a field by using ng-click in AngularJS ? 3 min read How to Add Dynamic Options for Multiple Selects Inside ng-repeat Directive ? 3 min read How to detect when an @Input() value changes in Angular? 3 min read How to open popup using Angular and Bootstrap ? 2 min read How to reload or re-render the entire page using AngularJS? 2 min read How to add input fields dynamically on button click in AngularJS ? 2 min read How to Create Button Dynamically with Click Event in Angular ? 2 min read How to use jQuery in Angular ? 2 min read AngularJS Examples 2 min read Like