My requirement is to get google places autocomplete suggestion only for the places in Bangalore, but if I search for any other place apart from bangalore then also I get the
Google is not providing autocomplete for particular city but we can do it manually. in my case i want to display address of 'Maharashtra' state.
this.GoogleAutocomplete = new google.maps.places.AutocompleteService();
this.GoogleAutocomplete.getPlacePredictions(
{
input: this.autocompleteFrom.input,
types: ['geocode'],
componentRestrictions: { country: 'in' },
},
(predictions, status) => {
this.autocompleteItemsFrom = [];
this.zone.run(() => {
if (predictions) {
console.log(predictions)
predictions.forEach((prediction) => {
var statearray = prediction.description.split(",")
var state = statearray[statearray.length - 2]
if(state === ' Maharashtra'){
this.autocompleteItemsFrom.push(prediction);
}
});
}
});
});
i hope it will help you.