By: Brandon Him - Brh55
Contributors: N/A
react: ^16.alpha.X
react-native: ^0.43.0
Most likely supported for older versions of RN > (~0.34)
Your component needs a deep link to open up Google Maps or Apple Maps for a location.
-
Use the
linking
library provided by react-nativeimport { Linking } from 'react-native';
-
The
.openURL
method can take the following URLS to open the corresponding map application:Linking.openURL(`http://maps.apple.com/?ll=${LATITUDE},${LONGITUDE}`)
- Google/Android:
geo:${LATITUDE},${LONGITUDE}
http://maps.google.com/maps?q=${LATITUDE},${LONGITUDE}
- iOS:
http://maps.apple.com/?ll=${LATITUDE},${LONGITUDE}
- Google/Android:
βοΈ Pro-Tip
UsePlatform.OS
(=== 'ios' || 'android') to allow cross-platform linking
π Note
You can also pass in thez
query param to set desired zoom levels
IE:http://maps.apple.com/?ll=37.484847,-122.148386&z=15
- Linking
- Platform
- react-native-open-maps - A wrapper lib that performs this logic