Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
添加预期类型参数会以意想不到的方式更改响应结果。
请求1: https ://maps.googleapis.com/maps/api/place/search/json?location=38.4551,-122.672045&radius=100&sensor=false&key=
请求 2: https ://maps.googleapis.com/maps/api/place/search/json?location=38.4551,-122.672045&radius=100&sensor=false&types=park&key=
两个请求都应返回名称为“Howarth Park”的地点,因为它属于公园类型。有趣的是,增加radius=500会带来预期的结果。但是,为什么它首先返回它而没有类型参数和相同的半径?
这是由于 Google Places API 处理搜索请求的方式。
Places API 将在指定半径内返回最多 20 个建立结果。此外,可以返回区域识别结果以帮助识别机构所在的区域。
如果 Places API 搜索请求中未指定类型,则这些区域标识结果不严格限制在请求中指定的半径范围内,但是当指定类型时,附加区域标识结果将严格限制在请求中指定的半径范围内要求。