1

问题是我想改变区域然后如果用户点击地图看到区域缩放并纠正不远所以因为我使用了区域道具但我注意到它使地图难以移动和变慢并且有时会挂起我尝试缩放解决方案是什么,这是我使用区域区域的代码

state = {
region: {latitude: 23.8859,
  longitude: 45.0792,
  latitudeDelta: 0.004757,
  longitudeDelta: 0.006866,
},}

const dbRef = firebase.firestore().collection("UserCoordinates").doc(firebase.auth().currentUser.uid.toString());
dbRef.get().then((res) => {
  if (res.exists) {
    console.log('res.data():', res.data());
    const data =  res.data();
    if(data.loc){
      const { region } =  this.state;
      this.setState({
        region:{
          ... region,
          latitude: data.loc.latitude,
          longitude:data.loc.longitude
        },
        markers: [{ latlng: data.loc }]
      });} 
  onRegionChange = (region) => {
// console.log('Region Change:', region);
this.setState({ region });
this.setState({
  locfollow:{
    followsUserLocation:false,
  }
 <MapView
      ref={ref => this.map = ref}
      style={[styles.map, { marginBottom: this.state.marginBottom }]}
      onMapReady={() => { this.setState({ marginBottom: 0 }) }}
      region={this.state.region}
      onRegionChange={this.onRegionChange}
      onPress={(e) => this.onMapPress(e)}
      showsUserLocation={true}
      followsUserLocation={this.state.locfollow.followsUserLocation}
      showsMyLocationButton={true}
      zoomEnabled={true}
      zoomControlEnabled={true}
      zoomTapEnabled={true}
    >
      {/*<Marker coordinate={{ latitude, longitude,}} title='loc' description='here'/>*/}
      {
        this.state.markers.map((marker, i) => (
          <Marker key={i} coordinate={marker.latlng} />
      ))
      }   </MapView>

它工作得很好并且使标记可保存但问题出在道具区域使地图有时难以移动和缩放请帮助我

4

0 回答 0