任何人都可以解释为什么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
}
)
}
>
这是因为Marker没有onLongPress事件:)
你不会在onLongPress
上找到MapView.Marker
事件。您可以通过其他View包装它,在这种情况下,您将在样式上遇到一些问题,因此相应地更新样式。
或遵循this方法