From 882d1cef0747cbc1f3f285a32553ef3f8c24b620 Mon Sep 17 00:00:00 2001 From: Ho Yin Cheng Date: Wed, 7 Mar 2018 14:24:16 -0500 Subject: [PATCH] Stop marker event propagation in order to prevent onPress for MapViews from being called when a marker is clicked. This makes the behavior of Apple Maps identical to that of the behavior of Google Maps on Android. This fixes react-community/react-native-maps#1132. --- lib/components/MapMarker.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/components/MapMarker.js b/lib/components/MapMarker.js index 5834d87838..5ab577b702 100644 --- a/lib/components/MapMarker.js +++ b/lib/components/MapMarker.js @@ -226,10 +226,6 @@ const propTypes = { onDragEnd: PropTypes.func, }; -const defaultProps = { - onPress() {}, -}; - class MapMarker extends React.Component { constructor(props) { super(props); @@ -295,13 +291,18 @@ class MapMarker extends React.Component { {...this.props} image={image} style={[styles.marker, this.props.style]} + onPress={event => { + event.stopPropagation(); + if (this.props.onPress) { + this.props.onPress(event); + } + }} /> ); } } MapMarker.propTypes = propTypes; -MapMarker.defaultProps = defaultProps; MapMarker.viewConfig = viewConfig; const styles = StyleSheet.create({