Search code examples
androidreact-nativereact-native-maps

Launching Google Maps app from react-native-maps


I'm displaying dynamic maps inside my app using using react-native-maps. I want Google Maps app to launch when a user presses some part of map, a text or an icon, so they can view the map also externally. How can I achieve that? Thanks.

  <MapView
    showsUserLocation
    style={styles.map}
    initialRegion={{
      latitude: placesLat,
      longitude: placesLng,
      latitudeDelta: 0.0022,
      longitudeDelta: 0.0121
    }}
  >
    <MapView.Marker
      coordinate={{ latitude: placesLat, longitude: placesLng }}
      title={placesTitle}
    />
  </MapView>

Solution

  • Add onMapPress function prop to MapView.Marker component and call Linking.openUrl as described here