【发布时间】:2018-11-01 11:35:57
【问题描述】:
这是我的 MapView 代码,
<MapView
style={styles.map}
initialRegion={
this.state.region
}
region={this.state.region}
onRegionChangeComplete={this.onRegionChange}
showsMyLocationButton
showsCompass
showsUserLocation
zoomControlEnabled
loadingEnabled
onMapReady={this.state.placesread ? this.getBreakfast : null}
>
{marker}
</MapView>
我的问题是当用户移动地图位置时,地图开始随机移动而不停止,如果不关闭地图窗口就无法停止。
当地图加载时,我得到标记并加载到地图上,类似于谷歌地图,我在地图上搜索此区域按钮,我使用 onRegionChangeComplete 将新区域存储到状态。
我的onRegionChangeComplete 代码是,
onRegionChange = async region => {
await this.setState({ region });
await this.setState({ regionChange: true });
};
【问题讨论】:
-
请分享
onRegionChangeComplete功能码 -
@Shivam 我已经更新了我的答案
-
我已经发布了答案,让我知道这是否适合你。
标签: android react-native react-native-maps