我目前正在尝试在地图视图上设置标记的坐标,但没有成功。
我试图设置坐标(经度,纬度)来设置状态,但仍然无法正常工作,状态已更新,但标记未设置。
<MapView
style={styles.map}
provider={PROVIDER_GOOGLE}
showUserLocation
followUserLocation
loadingEnabled
region={this.getMapRegion()}
>
<Polyline coordinates={this.state.routeCoordinates} strokeWidth={5} />
<Marker.Animated
ref={marker => {
this.marker = marker;
}}
coordinate={this.state.coordinate}
/>
<MapView.Marker
coordinate={{ latitude: this.state.latitudePointUn,
longitude: this.state.longitudePointUn}}
title={"title"}
description={"description"}
/>
</MapView>
launchGame(){
if (this.state.texteBouton=="Commencer")
{
this.setState({texteBouton: "Abandonner"});
this.setState({latitudePointUn:this.state.course.points[0].latitude });
this.setState({longitudePointUn:this.state.course.points[0].longitude })
console.log("du coup ?"+ this.state.latitudePointUn + "----------------" + this.state.longitudePointUn);
this.startStopStopWatch();
this.forceUpdate();
}
}
我原本希望我的标记会更新,但现在还不能。 我要更新标记的原因是因为我需要在地图上放置3个标记,并且必须通过查询获取它们的位置。问题是,如果我直接将不同的位置放在标记中,则该功能不起作用,因为该组件已经渲染(因此我的位置为空)...您有任何想法吗?