【问题标题】:React native maps draggable marker onDragEnd position?反应原生地图可拖动标记onDragEnd位置?
【发布时间】:2019-05-19 10:48:37
【问题描述】:

我刚开始使用 react native maps~0.22.1,在获取可拖动标记 onDragend 新位置时遇到问题; 我遵循了文档,即使它有点飘忽不定,但结果是未定义的;

这是我的代码:

<Marker
        ref={(ref) => { this.marker = ref; }}
        draggable
        onDragEnd={(t, map, coords) => this.setDestination(coords)}
        coordinate={destination}
        position={destination}
        centerOffset={{ x: -18, y: -60 }}
        anchor={{ x: 0.69, y: 1 }}
        pinColor={COLOR.marker}
        onDragStart={() => this.setMarkerPosition()}
      />

setDestination 函数:

setDestination(coords) {
    const { destination } = this.props;
    const lat = coords.lat();
    const long = coords.lng();
    console.log('seperate:', lat, long);
    console.log('destina:', coords);
    this.props
      .dispatch($setDestination(coords.lat(), coords.lng()))
      .catch((error) => this.props.dispatch(Activity.$toast('failure', error.message)));

    this.setState((prevState) => ({
      isVisible: !prevState.isVisible,
      destination: destination[0].fullAddress,
    }));
  }

【问题讨论】:

    标签: javascript google-maps react-native react-native-maps


    【解决方案1】:

    onDragEnd={(e) => {console.log('dragEnd', e.nativeEvent.coordinate)}}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-17
      • 2020-02-24
      • 2019-02-28
      • 2019-06-19
      • 2020-04-11
      • 1970-01-01
      • 2018-12-09
      相关资源
      最近更新 更多