我正在尝试使用onLongPress与本地反应原生,但它不起作用

问题描述 投票:0回答:2

任何人都可以解释为什么onlongPress不工作。我正在使用本地反应世博会。 MapView是从expo导入的

<MapView.Marker
              style={styles.map}
              key={marker.pageid}
              coordinate={coords}
              description={`distance: ${marker.distance}m`}
              longPressDelay={1000}
              onLongPress={() => {
                console.log('hit');
              }}
              onPress={() =>
                this.map.fitToCoordinates(
                  [
                    {
                      latitude: this.props.latitude,
                      longitude: this.props.longitude
                    },
                    coords
                  ],
                  {
                    edgePadding: {
                      top: 150,
                      right: 5,
                      bottom: 5,
                      left: 10
                    },
                    animated: true
                  }
                )
              }
            >
react-native android-mapview expo
2个回答
0
投票

这是因为Marker没有onLongPress事件:)


0
投票

你不会在onLongPress上找到MapView.Marker事件。您可以通过其他View包装它,在这种情况下,您将在样式上遇到一些问题,因此相应地更新样式。

或遵循this方法

© www.soinside.com 2019 - 2024. All rights reserved.