react-native-map-link icon indicating copy to clipboard operation
react-native-map-link copied to clipboard

Using showLocaiton links straight to maps

Open szarbartosz opened this issue 1 year ago • 2 comments

Using react-native-map-link with expo in the following way:

export const linkToMaps = async (latitude: number, longitude: number, label: string) => {
  await showLocation({
    latitude: latitude,
    longitude: longitude,
    title: label,
    dialogTitle: t('openInMaps'),
    dialogMessage: t('whichAppToUse'),
    cancelText: t('cancel'),
  });
};

The function is triggered by a button click - when tried it via expo-go on an Android device the modal with alternative map apps was presented - when doing so on the iOS simulator or iOS device via expo-go, there is an immediate link to the iOS maps without presentation of the alternatives. (I added the react-native-map-link plugin to the app.json)

szarbartosz avatar Jun 29 '24 23:06 szarbartosz

When using Expo Go, only certain URL schemes will be whitelisted, regardless of whether the plugin is added or not.

If that leaves only one available maps option that can be detected, it will open that app directly. A native build on your app (e.g. not using Expo Go) on a device with more than one of the supported apps installed should show a menu with options.

tschoffelen avatar Jul 05 '24 14:07 tschoffelen

You can also force it to show google maps as an option in expo go using the alwaysIncludeGoogle flag.

mattHollywood87 avatar Jul 07 '24 10:07 mattHollywood87

Thank you for the response @tschoffelen @mattHollywood87 - closing as complete 🙌

szarbartosz avatar Jul 08 '24 07:07 szarbartosz