Ahm*_*Ali 1 react-native react-native-ios react-native-maps
我正在开发一个使用 React-native-maps 的 React Native 应用程序,目前我坚持获取当前区域的左上角(纬度和经度)和右下角(纬度和经度)
<MapView.Animated
onRegionChange={this.onRegionChange.bind(this)}
showsUserLocation
initialRegion={{
latitude: coords.latitude,
longitude: coords.longitude,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA,
}}
style={{ flex: 1 }}
>
<MapView.Marker
coordinate={{ latitude: coords.latitude, longitude: coords.longitude }}
>
<MapView.Callout style={{ position: 'relative', width: 150}}>
<PlaceCard />
</MapView.Callout>
</MapView.Marker>
</MapView.Animated>
Run Code Online (Sandbox Code Playgroud)
知道如何得到它吗?!
如果 ( REGION.latitude, REGION.longitude) 是地图的中心,增量是地图上显示的最小和最大纬度/经度之间的距离(以度为单位),那么您应该能够获得左上角和右下角点,如下所示:
{
latlng: {
latitude: REGION.latitude+(REGION.latitudeDelta/2),
longitude: REGION.longitude-(REGION.longitudeDelta/2)
},
title:'topLeft'
},
{
latlng: {
latitude: REGION.latitude-(REGION.latitudeDelta/2),
longitude: REGION.longitude+(REGION.longitudeDelta/2)
},
title:'bottomRight'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2651 次 |
| 最近记录: |