react-native-maps: Coordinate property missing iOS GoogleMaps in MapView.Marker onPress

Is this a bug report?

Yes

Have you read the Installation Instructions?

Yes

Environment

react-native-maps@0.17.1 react: 16.0.0 react-native: 0.50.3

Target Platform: iOS 11.1.2 iPhone 6S Map: GoogleMaps

Steps to Reproduce

  1. Add a MapView.Marker to a MapView
  2. Add a onPress prop to the MapView.Marker
  3. In the callback function the value of the event’s nativeEvent, the coordinate property is missing.

Expected Behavior

I expected to see a coordinate property in the event object.

Actual Behavior

The coordinate property is non-existent. If I remove the map provider and use AppleMaps then the coordinate value shows, GoogleMaps (our required platform) returns no coordinate property.

Reproducible Demo

https://snack.expo.io/ByIuKY9EM

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

~~@rborn Doesn’t appear to be rendering. Any ideas? Created a snack: https://snack.expo.io/BJFFEhi4z~~ Sorted (coordinate needed to be singular). Thanks so much for your help! I’ll leave the report open as I assume this is something that needs fixing, but if you feel it would be better off closed as this is a very simple workaround, feel free to do so.

@FaBeyyy That’s because in my example I just return coordinate from the onPress inside my custom marker. Here I fixed it for you in this Snack: https://snack.expo.io/B1Rv4jxrz

@jskidd3 something like this (untested/pseudocode):

class MyMarker extends Component {
    onPress  = () => {
        this.props.onPress(this.props.coordinates)
    }
    
    render() {
        return <MapView.Marker onPress={this.onPress} coordinate={this.props.coordinates}/>
    }
}

and in your file you use MyMarker instead of MapView.Marker. Makes sense?