我希望通过距离让我所在机场附近的机场附近 . 我使用此网址使用谷歌地方api附近的搜索请求:https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=51.9143924,-0.1640153&sensor=true&key=api_key&radius=50000&types=airport我得到的结果是稀疏的,没有任何订单 . 我尝试了rankby = distance但没有出现结果 . 并根据https://developers.google.com/places/documentation/search#PlaceSearchRequests documentation " radius must not be included if rankby=distance" .
3 回答
是的,您不能在同一请求中使用 radius 和 rankBy . 但你可以使用 rankBy=distance ,然后根据
geometry.location.lat
和geometry.location.lng
计算距离 . 对于groovy中的exmaple,我做过这样的事情:GeoPosition
和Place
类是由我实现的,所以不要指望在核心库中找到它们:)距离算得那样(Haversine公式):
你不能一起使用
radius
和rankby
这就是问题所在截至2018年10月,Google已将初始位置添加为nearSearch的一部分,如下所示:
上述代码将使博物馆返回靠近距离asc指定的位置 . 在这里查找更多信息:https://developers.google.com/maps/documentation/javascript/examples/place-search