Skip to content

Commit

Permalink
Stop marker event propagation in order to prevent onPress for MapView…
Browse files Browse the repository at this point in the history
…s 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-native-maps#1132.
  • Loading branch information
hysan committed Mar 7, 2018
1 parent 8f7bd9e commit 882d1ce
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/components/MapMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ const propTypes = {
onDragEnd: PropTypes.func,
};

const defaultProps = {
onPress() {},
};

class MapMarker extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 882d1ce

Please sign in to comment.