Google maps react native中MapView内的动态Lat Lang
我使用的是Google maps react native中MapView内的动态Lat Lang,google-maps,react-native,android-mapview,expo,Google Maps,React Native,Android Mapview,Expo,我使用的是expoMapView。我正在搜索如何根据手机的高度和宽度查找lat和land的解决方案。例如:[[lat,lang],[lat,lang],[lat,lang],[lat,lang] 有人能帮我澄清一下吗。当您通过onRegionChange或任何其他类似事件从MapView获取区域对象时,该对象包含4个属性 示例 const region = { latitude: 37.78825, longitude: -122.4324, latitudeDelta: 0.092
expo
MapView
。我正在搜索如何根据手机的高度和宽度查找lat和land的解决方案。例如:[[lat,lang],[lat,lang],[lat,lang],[lat,lang]
有人能帮我澄清一下吗。当您通过
onRegionChange
或任何其他类似事件从MapView
获取区域对象时,该对象包含4个属性
示例
const region = {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}
增量值表示要显示的最小点和最大点之间的差值
(图片来源)
使用此信息,可以计算地图视图的4个角(地图边界),也可以使用它们设置缩放级别
示例(未进行测试,因此计算可能存在一些错误)
如果我们在下面示例中给出的区域上设置MapView
,我们的四个角将是下面计算的位置
const leftTopLongitude = region.longitude - (region.longitudeDelta / 2);
const rightTopLongitude = region.longitude + (region.longitudeDelta / 2);
const leftTopLatitude = region.latitude + (region.latitudeDelta / 2);
const rightTopLatitude = region.latitude + (region.latitudeDelta / 2);
const leftBottomLongitude = region.longitude - (region.longitudeDelta / 2);
const rightBottomLongitude = region.longitude + (region.longitudeDelta / 2);
const leftBottomLatitude = region.latitude - (region.latitudeDelta / 2);
const rightBottomLatitude = region.latitude - (region.latitudeDelta / 2);
通过
onRegionChange
或任何其他类似事件从MapView
获取区域对象时,该对象包含4个属性
示例
const region = {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}
增量值表示要显示的最小点和最大点之间的差值
(图片来源)
使用此信息,可以计算地图视图的4个角(地图边界),也可以使用它们设置缩放级别
示例(未进行测试,因此计算可能存在一些错误)
如果我们在下面示例中给出的区域上设置MapView
,我们的四个角将是下面计算的位置
const leftTopLongitude = region.longitude - (region.longitudeDelta / 2);
const rightTopLongitude = region.longitude + (region.longitudeDelta / 2);
const leftTopLatitude = region.latitude + (region.latitudeDelta / 2);
const rightTopLatitude = region.latitude + (region.latitudeDelta / 2);
const leftBottomLongitude = region.longitude - (region.longitudeDelta / 2);
const rightBottomLongitude = region.longitude + (region.longitudeDelta / 2);
const leftBottomLatitude = region.latitude - (region.latitudeDelta / 2);
const rightBottomLatitude = region.latitude - (region.latitudeDelta / 2);
棒极了,兄弟,它就像一个符咒。Thnx a ton bro:)我的状态值和道具值在
onRegionChange
method.中未定义。!!我也不能调用任何方法。为什么?“原因是什么?”贝基首先,冷静下来。你不需要那么多感叹号。其次,您的问题与此的上下文有关。您需要绑定函数才能在其中使用this
。棒极了,兄弟,它就像一个符咒。Thnx a ton bro:)我的状态值和道具值在onRegionChange
method.中未定义。!!我也不能调用任何方法。为什么?“原因是什么?”贝基首先,冷静下来。你不需要那么多感叹号。其次,您的问题与此的上下文有关。您需要绑定函数才能在其中使用this
。