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

[react-native-hms-map] onInfoWindowClick event not firing for custom InfoWindow #165

Closed anyamiletic closed 2 years ago

anyamiletic commented 2 years ago

Description When implementing a custom info window using HMSInfoWindow, the onInfoWindowClick and onInfoWindowLongClick events are not firing. The onInfoWindowClose event does fire as expected.

Expected behavior The click events fire on click

Current behavior The events only fire on the default Info Window, or, if using a custom HMSInfoWindow, when there are only Text elements as children. As soon as a View is used (like in the official react-native example) this listeners never fire.

Screenshots official example modified to show callback logs:

nav finished

Environment

Other You can reproduce this bug by using the official example project at https://github.com/HMS-Core/hms-react-native-plugin/tree/a796c2550e0c7a0f44c598056b427a58ac5abd47/react-native-hms-map/example In screens/Markers.js add info window callbacks to each marker, or even just to the marker rendering the custom info window:

          <HMSMarker
            icon={{
              uri: Image.resolveAssetSource(
                require("../assets/galata-tower.png")
              ).uri,
              width: 140,
              height: 150,
            }}
            coordinate={{
              latitude: 41.02564844393837,
              longitude: 28.974169719709817,
            }}
            onInfoWindowClick={(e) => console.log('HMSMarker onInfoWindowClick: ', e.nativeEvent)}
            onInfoWindowClose={(e) => console.log('HMSMarker onInfoWindowClose: ', e.nativeEvent)}
            onInfoWindowLongClick={(e) => console.log('HMSMarker onInfoWindowLongClick')}
          >
            {this.CustomInfoWindow()}
        </HMSMarker>
ozcanozgur commented 2 years ago

Hi @anyamiletic ,

There is an example related to this issue in our React Native Map document. We are using TouchableHighlight component to trigger custom info window click events. You can check the sample code.

Thank you for your interest.