您在问题中提到的邮政编码与多个地区重叠。 Google 在地址组件中显示了一个地方,这可能是他们认为最突出的地方。
但是,在响应中,您可以看到邮政编码重叠的地区列表。只需查看响应中的 postcode_localities 字段即可。
例如,对于邮政编码 52241
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A52241%7Ccountry%3AUS&key=YOUR_API_KEY
你会看到
"place_id":"ChIJbaAjdYZD5IcRBfptU5KhMJk",
"postcode_localities":[
"Coralville","Iowa City","Oakdale"
],
"types":[
"postal_code"
]
对于邮政编码 43065
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A43065%7Ccountry%3AUS&key=YOUR_API_KEY
响应将包含
"place_id":"ChIJW2TudRTsOIgR8v0-4d19bNA",
"postcode_localities":[
"Powell","Shawnee Hills"
],
"types":[
"postal_code"
]
最后是邮政编码 11040
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A11040%7Ccountry%3AUS&key=YOUR_API_KEY
你会得到
"place_id":"ChIJ28UCx5hiwokRf_9UXmJHg5I",
"postcode_localities":[
"GARDEN CITY P","Garden City Park","Hillside Manor","Manhasset Hills","New Hyde Park","North Hills","North New Hyde Park"
],
"types":[
"postal_code"
]
请注意,您要查找的位置存在于 postcode_localities 数组中。
我希望这会有所帮助!