React Native地图获取左上角和右下角经纬度
React Native maps get top left corner and bottom right corner latitude and longitude
我正在开发一个使用 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>
知道如何获得吗?!
如果 (REGION.latitude
, REGION.longitude
) 是地图的中心,增量是地图上显示的最小值和最大值 lat/long 之间的距离(以度为单位),则你应该能够像下面这样得到 topLeft 和 bottomRight 点:
{
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'
}
我正在开发一个使用 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>
知道如何获得吗?!
如果 (REGION.latitude
, REGION.longitude
) 是地图的中心,增量是地图上显示的最小值和最大值 lat/long 之间的距离(以度为单位),则你应该能够像下面这样得到 topLeft 和 bottomRight 点:
{
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'
}