Google places autocomplete - location and radius not working

前端 未结 3 1437
谎友^
谎友^ 2021-01-12 21:52

Im trying to set the google places autocomplete to sort the results from the nearest to a point. I have a code like this...

         


        
3条回答
  •  没有蜡笔的小新
    2021-01-12 22:37

    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

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

    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

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

提交回复
热议问题