I am new to Google Map APIs.. I wish to use dropdown where user will type location and correspondingly google will give suggestions.. but problem is i dont want Google to give Street & District names..I want only City, State & country names to be autosuggested..My code is as follows
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places&language=en-AU"></script>
<script>
var autocomplete = new google.maps.places.Autocomplete($("#address")[0], {});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
console.log(place.address_components);
});
</script>
</body>
How to get only City & Country name from the API ? Thanks In advance
Add 'regions' to the options in the constructor:
var acOptions = {
types: ['(regions)']
};
var autocomplete = new google.maps.places.Autocomplete($("#address")[0], acOptions);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With