I have the following jQuery code that works well with getting a list of cities for the selected country.
var city; var place; $('#city').on('focus',function(){ input = this, options = { types: ['(cities)'], componentRestrictions: { country: $('#country option:selected').val() } }; city = new google.maps.places.Autocomplete(input, options); google.maps.event.addListener(city, 'place_changed', function() { place = city.getPlace(); $(input).val(place.address_components[0].long_name); }) })
In principle, as soon as a person selects a place, he replaces the value in the input field with the value "city" without a country.
The drop-down menu looks a little silly if the user has already selected the country, so does anyone know if it is possible to display the city name JUST if you defined a componentRestrictions value that restricts the results to the country?
I find my current installation method as soon as the choice has been made a little ... trash really ...
Andrew Willis
source share