React Native地图获得左上角和右下角的纬度和经度

时间:2017-03-12 05:05:57

标签: react-native react-native-ios react-native-maps

我正在开发一个使用React-native-maps的本机应用程序,目前我正在努力获取当前区域左上角(lat& long)和右下角(lat& long)

<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>

如何获得它的任何想法?!

1 个答案:

答案 0 :(得分:3)

如果(REGION.latitudeREGION.longitude)是地图的中心,而增量是地图上显示的最小和最大纬度/经度之间的距离(以度为单位),那么您应该能够得到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'

            }
相关问题