I also tried to trigger the event
google.maps.event.trigger(autocomplete, 'place_changed');
but autocomplete.getPlace() is still return undefined until I change the city manually.
Any suggestions please?
I also tried to trigger the event
google.maps.event.trigger(autocomplete, 'place_changed');
but autocomplete.getPlace() is still return undefined until I change the city manually.
Any suggestions please?
From google docs: getPlace(): Returns the details of the Place selected by user if the details were successfully retrieved. Otherwise returns a stub Place object, with the name property set to the current value of the input field.
Using for example the following code:
var autocompleteSearch = new google.maps.places.Autocomplete(searchField, searchOptions);
setInterval(function() {
var place = autocompleteSearch.getPlace();
console.log('place: ');
console.log(place);
}, 5000);
you will get 'undefined' in console if you wrote for example "qwertyasdfgh". Until you press Enter: after that the result will be:
place:
Object {name: "qwertyasdfgh"}
So, it's not much useful. No address_components
, geometry
...