使用反向地理编码获取街道名称

Get street name with Reverse Geocoding

我正在尝试使用 google 地图示例 https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse 通过反向地理编码获取街道、城市和国家/地区,但它给我的只是 .formatted_address 而不是街道、城市和国家/地区。

有什么办法可以分别得到街道、城市和国家吗?

FIDDLE

使用 .address_components 而不是 .formatted_address,通过地址组件,您可以将结果分解为不同的变量,然后将其调用到您的信息中 window。 Fiddle Link