【发布时间】:2015-11-25 17:37:55
【问题描述】:
我正在使用 react-native。如何获取 iOS 地图的中心坐标?
【问题讨论】:
标签: ios dictionary react-native
我正在使用 react-native。如何获取 iOS 地图的中心坐标?
【问题讨论】:
标签: ios dictionary react-native
发件人:https://facebook.github.io/react-native/docs/mapview.html#content
region {latitude: number, longitude: number, latitudeDelta: number, longitudeDelta: number}
地图要显示的区域。
区域由中心坐标和跨度定义 要显示的坐标。
因此,您可以使用地图的 region 属性获取中心坐标,例如
getCoordinates(region) {
return [{
longitude: region.longitude,
latitude: region.latitude,
}];
},
如果您需要一个全局变量来传递给getCoordinates,您可以使用一个全局变量,该变量会随着onRegionChange 等各种状态变化而设置一个新值。
【讨论】: