HMS-Core / hms-react-native-plugin

This repo contains all of React-Native HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
240 stars 68 forks source link

Map kit HmsMarker event is not working #143

Closed liho00 closed 2 years ago

liho00 commented 3 years ago

Description HmsMarker event is not working

   <HMSMap
        style={props.mapStyle || { height: getXdp(80), marginBottom: 20 }}
        camera={{
          target: { latitude: location.lat, longitude: location.lng },
          zoom: 15,
        }}
        mapType={MapTypes.NORMAL}
        rotateGesturesEnabled={false}
        scrollGesturesEnabled={true}
        zoomControlsEnabled={true}
        zoomGesturesEnabled={true}
        buildingsEnabled={true}
        // trafficEnabled={true}
        pointToCenter={{ x: 10, y: 10 }}
        gestureScaleByMapCenter={true}
        myLocationEnabled={true}
        myLocationButtonEnabled={true}
        scrollGesturesEnabledDuringRotateOrZoom={false}
        // onCameraUpdateFinished={e => setMapActive(false)}
        // onCameraUpdateCanceled={e => setMapActive(false)}
        // onCameraIdle={e => {
        //   console.log('HMSMap onCameraIdle: ', e.nativeEvent);
        //   setMapInactive();
        // }}
        // onMapReady={e => console.log('HMSMap onMapReady: ', e.nativeEvent)}
        // onCameraMoveCanceled={e => setMapActive(false)}
        // onCameraMove={e => setMapActive(true)}
        // onCameraMoveStarted={e => {
        //   setMapActive(true);
        // }}
        // onMapClick={e => setMapActive(true)}
        // onMapLoaded={e => console.log('HMSMap onMapLoaded: ', e.nativeEvent)}
        // onMapLongClick={e =>
        //   console.log('HMSMap onMapLongClick: ', e.nativeEvent)
        // }
        // onMyLocationButtonClick={e =>
        //   console.log('HMSMap onMyLocationButtonClick: ', e.nativeEvent)
        // }
        // onMyLocationClick={e =>
        //   console.log('HMSMap onMyLocationClick: ', e.nativeEvent)
        // }
        // onPoiClick={e => console.log('HMSMap onPoiClick: ', e.nativeEvent)}
        // onSnapshotReady={e =>
        //   console.log('HMSMap onSnapshotReady: ', e.nativeEvent)
        // }
      >
        <HMSMarker
          draggable={true}
          coordinate={{
            latitude: location.lat,
            longitude: location.lng,
          }}
          onDragStart={e =>
            console.log('HMSMarker onDragStart: ', e.nativeEvent)
          }
          onDrag={e => console.log('HMSMarker onDrag: ', e.nativeEvent)}
          onDragEnd={e => console.log('HMSMarker onDragEnd: ', e.nativeEvent)}
        />
      </HMSMap>

Expected behavior HmsMarker ondragend event should return the marker location: {lng,lat}

Current behavior HmsMarker ondragend event not returning the marker location: {lng,lat} got empty object

Screenshots image

Logs

 LOG  Service is initialized successfully
 LOG  e.nativeEvent {}
 LOG  Service is initialized successfully
 LOG  HMSMarker onDragStart:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDragEnd:  {}
 LOG  HMSMarker onDragStart:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDrag:  {}
 LOG  HMSMarker onDragEnd:  {}

Environment

Other Add any other context about the problem here

ozcanozgur commented 2 years ago

Hi @liho00 ,

We have released the new version of map kit and issue is fixed. Now onDrag event returns the marker location as expected. You can access the new version of map kit from npm.

npm link -> @hmscore/react-native-hms-map

Thanks for your attention.