Created
August 2, 2017 14:49
-
-
Save rajaishwary/3baa2b90655f16683b2889d66bb29cdb to your computer and use it in GitHub Desktop.
[React-Native] Open navigation GMaps by default if exists otherwise open Apple maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openMaps(lat, long) { | |
//Try to open GMaps by default if exists otherwise open Apple maps | |
Linking.canOpenURL(`comgooglemaps://?saddr=My+Location&daddr=${lat},${long}`).then(supported => { | |
if (supported) { | |
Linking.openURL(`comgooglemaps://?saddr=My+Location&daddr=${lat},${long}`); | |
} else { | |
Linking.openURL(`http://maps.apple.com/?daddr=${lat},${long}`); | |
} | |
}).catch(err => console.error('An error occurred', err)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment