![]() |
VOOZH | about |
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.
This module is a wrapper for Google Places Autocomplete js library. It allows us to integrate locations autocomplete to our project.
For npm:
npm install ngx-google-places-autocomplete
For yarn:
yarn add ngx-google-places-autocomplete
<script src="https://maps.googleapis.com/maps/api/js?key=<Your API KEY>&libraries=places&language=en"></script>
import { GooglePlaceModule } from "ngx-google-places-autocomplete";
@NgModule({
imports: [
GooglePlaceModule
],
Note: In country Array there is "AU" added for Australia, you can add any other country according to you.
app.module.ts
app.component.html
app.component.ts
Run development server using ng serve and write some location to input field to see Autocomplete locations.
👁 Image