oflcad
oflcad

Reputation: 515

React native maps draggable marker onDragEnd position?

I just started using react native maps~0.22.1, and I am having trouble acquiring the draggable marker onDragend new position; I followed the documentation even though it is a bit vag, but the result is undefined;

Here is my code:

<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 function:

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,
    }));
  }

Upvotes: 3

Views: 11400

Answers (1)

DDas
DDas

Reputation: 306

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

Upvotes: 13

Related Questions