我正在使用React-Native,如何在iOS地图上获取中心坐标?
来自: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
设置新值。