Deepak Shinde Deepak Shinde - 1 year ago 84
Javascript Question

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 auto complete but I want to dynamically pass lag. and lat. to this function. How can I do that? please help me.
I'd like to hve 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