【发布时间】:2020-05-05 11:18:35
【问题描述】:
我已经使用初始区域坐标初始化了一个反应原生地图。
<MapView
style={{ ...styles.map, marginTop: this.state.marginTop }}
initialRegion={this.state.region}
showsUserLocation={true}
followsUserLocation={true}
onMapReady={this.onMapReady}
onRegionChangeComplete={this.onRegionChange}
>
<MapView.Marker
coordinate={this.state.region}
title={"Your location"}
draggable
/>
</MapView>
现在从服务器获取一个新位置,它有一个新的纬度和经度,我想在我的地图上显示为一个新的标记。我在 ononRegionChange 上用新的纬度和经度更新了该地区。
但我无法在区域更改时调用新的标记位置。有谁能帮帮我吗?
【问题讨论】:
-
你能分享你更新新区域的代码吗?
-
this.setState({ region: { latitude: myArray[0], longitude: myArray[1] },这就是我更新状态的方式
标签: javascript react-native react-native-android react-native-maps