Google places autocomplete - location and radius don't work

I am trying to set google autocomplete to sort the results from nearest to 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 );

types and componentRestrictions work fine, but location and radius don't work.

+5
source share
2 answers

See the documentation

It states:

radius | Defines the distance (in meters) over which Place results should be returned. The maximum allowable radius is 50,000 meters. Please note that the radius should not be included if the rank = distance is specified (described in the "Optional parameters below" section).

, : rankby = distance:

| . . 50 . , .

javascript

+5

, - , , ,

 var request = {
    location: pyrmont,
        bounds: map.getBounds(),
    radius: 2000,
    zoom: 15,
    types: ['restaurant']
  };

, , , , ,

 var request = {
    location: pyrmont,
        bounds: map.getBounds(),
    radius: '2000',
    zoom: 15,
    types: ['restaurant']
  };
0

All Articles