如何从谷歌地图位置获取城市名称?

时间:2018-05-11 11:36:46

标签: google-maps react-native expo

我正试图从地理编码返回的内容中获取城市名称,但似乎没有以任何方式工作我已经尝试过。任何人都可以帮我恳求吗?

这里是我获取位置数据的地方,该数据返回一个包含区域,街道,城市等数组的对象,如下所示

这一行:

<Text>Location: {this.state.locationResult}</Text>

返回此

[{"region":"England","street":"Holborn street","city":"London"}]

我尝试过使用locationResult [0] .city,但仍然无法正常工作。

1 个答案:

答案 0 :(得分:0)

这个:

let obj = this.state.locationResult;
<Text>Location: {obj[0].city}</Text>