Google商家信息:选择所有地点类型只会返回前40个结果

时间:2015-10-28 17:46:51

标签: android google-places-api

我目前正在使用Google Places API并在我的查询中指定了所有地点类型:

  

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-25.300968,29.124129&types=accounting|airport|amusement_park|aquarium|art_gallery|atm|bakery|bank|bar|beauty_salon|bicycle_store|book_store|bowling_alley|bus_station|cafe|campground|car_dealer|car_rental|car_repair|car_wash|casino|cemetery|church|city_hall|clothing_store|convenience_store|courthouse|dentist|department_store|doctor|electrician|electronics_store|embassy|establishment|finance|fire_station|florist|food|funeral_home|furniture_store|gas_station|general_contractor|grocery_or_supermarket|gym|hair_care|hardware_store|health|hindu_temple|home_goods_store|hospital|insurance_agency|jewelry_store|laundry|lawyer|library|liquor_store|local_government_office|locksmith|lodging|meal_delivery|meal_takeaway|mosque|movie_rental|movie_theater|moving_company|museum|night_club|painter|park|parking|pet_store|pharmacy|physiotherapist|place_of_worship|plumber|police|post_office|real_estate_agency|restaurant|roofing_contractor|rv_park|school|shoe_store|shopping_mall|spa|stadium|storage|store|subway_station|synagogue|taxi_stand|train_station|travel_agency|university|veterinary_care|zoo&key=&安培; rankby =距离

我只能通过在REST调用中指定所有地点类型来获得前40个结果 - 最大搜索结果大小为60个。根据这个帖子,如果我们指定所有地点类型并且next_page_token将不会超出前40个项目(超出第2页),我们只能得到前40个结果:

https://code.google.com/p/gmaps-api-issues/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal&groupby=&sort=&id=6998

如果是这种情况,则意味着我要搜索的地点必须预先确定/设置,或者用户必须在进行nearBy地点搜索之前指定地点。

我搜索的一些地方非常偏远,这意味着可能没有法院大楼和#34;那里 - 它可能只是非洲各地的森林。我希望用户能够找到最近的人造地方。

如果我无法搜索超过40个地方,那是否可以找到某个地区更受欢迎的地方类型?例如,当我打开手机时,我希望能够看到附近有这些地点类型:

  • 3 ATM
  • 7 Shoe_store
  • 1 travel_agency

这样我可以将nearBy搜索设置为仅这些地点类型吗?

1 个答案:

答案 0 :(得分:0)

正如https://code.google.com/p/gmaps-api-issues/issues/detail?id=6998#c4所指出的那样,将types设置为包含每种类型都与完全省略types相同 - 除非它甚至没有这样做,因为您最多只能指定20个类型。

因此,请关闭该参数,它不会帮助您,甚至不会按照您的想法行事。 (实际上,通过包含每个type,您会得到一个很长的URL,这可能会导致问题。)

另外,请注意,不推荐一次搜索多个类型。见http://googlegeodevelopers.blogspot.com.au/2016/02/changes-and-quality-improvements-in_16.html

  

从2016年2月16日开始,我们将使用新类型搜索参数替换类型限制参数。如果您一直在使用附近搜索,文本搜索或雷达搜索的类型参数,那么您将受到影响。

     

类型搜索与类型限制类似,但它仅支持   每个请求一种类型。

     

使用types参数和指定多种类型的请求   (例如,types=hospital|pharmacy|doctor)将继续   返回结果直到2017年2月16日,但我们不建议使用   搜索请求中的多种类型。 在该日期之后,请求   将不再支持多种类型。确保最佳状态   可能为您的用户搜索结果,我们建议您使用单个搜索结果   输入搜索请求。

(强调我的。)

所以我认为你应该简单地省略types参数。例如。 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-25.300968,29.124129&rankby=distance&key=YOUR_KEY