Deepak Shinde Deepak Shinde - 1 year ago 84
Javascript Question

Bias results of place autocomplete for selected city

I have a drop-down menu for selecting city and an autocomplete text-box. I want only locations form selected city in drop-down.

function initAutocomplete() {
autocomplete = new google.maps.places.Autocomplete(
bounds: new google.maps.Circle({
center: new google.maps.LatLng( 18.520430,73.856744 ),
radius: 500
types: ['establishment']

autocomplete.addListener('place_changed', function(){});

I use above code for place autocomplete, but I want to dynamically pass longitude and latitude to this function. How can I do that? Please help me.
I'd like to have functionality like .

Answer Source

When new city is selected and you have new lat,lng of that city, use this piece of code to update the bound of autocomplete widget with new value of lat and lng:

var bounds = new google.maps.LatLngBounds();
var latLng = new google.maps.LatLng(lat, lng);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download