我正在使用 react-native。如何获取 iOS map 上的中心坐标?
最佳答案
发件人:https://facebook.github.io/react-native/docs/mapview.html#content
region {latitude: number, longitude: number, latitudeDelta: number, longitudeDelta: number}
The region to be displayed by the map.
The region is defined by the center coordinates and the span of coordinates to display.
因此,您可以使用 map 的 region
获取中心坐标属性,使用类似的东西
getCoordinates(region) {
return [{
longitude: region.longitude,
latitude: region.latitude,
}];
},
如果你需要一个全局变量传递给getCoordinates
,您可以使用一个全局变量,该变量随各种状态变化时设置的新值而变化,例如 onRegionChange
.
关于ios - 如何在 react native map 上获取中心坐标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32315425/