使用 Google API 的反向地理编码 - 如何首先获取附近的位置?

Reverse Geocoding using Google API - How to get nearby location first?

我正在使用 Google 的地理编码器 API 对当前附近位置进行反向地理编码。当我在我的国家寻找一个地方时,不知何故我会被重定向到另一个国家同名的另一个地方?

是否可以先获取附近地点的位置,然后再将我引导到其他地方?

您可以通过 componentRestrictions-属性 将搜索限制在特定国家/地区。

示例:

{'address': 'Philadelphia',componentRestrictions:{country:'de'}}

...地理编码器将 return 德国的一个名为 "Philadelphia"

的小村庄,而不是美国的费城

https://maps.googleapis.com/maps/api/geocode/json?address=Philadelphia&components=country:de