Im trying to set the google places autocomplete to sort the results from the nearest to a point. I have a code like this...
var defaultPlace = new google.maps.LatLng(49.227463, 16.546097);
var optionsAuto = {
location: defaultPlace,
radius: 20000,
types: ['geocode'],
componentRestrictions: {
country: 'cz'
}
};
var autocomplete = new google.maps.places.Autocomplete( inputStart, optionsAuto );
the types and componentRestrictions works great but the location and radius doesn't seems to be working.
Look at the documentation
It states:
It sound like you want the optional parameter: rankby=distance:
Which is also available in the javascript service
Working Example
to return places just in radius you need to set strictbounds to true.
The main problem for me right now is that Autocomplete doesn't have rankBy. see here
It's possible that someone may not be agree with me but In my case i defined the radius without quotes i.e like below
So it didn't make any difference on radius and showed the result independent of radius but when i applied quotes on it , radius parameter seems to be working