Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking Map in React Native

I am using RN 0.20 for iOS. I want to make a link where if you click that link, it will redirect you to the Map apps available in the phone with its coordinate. This is what I have done using Linking component.

redirectToMap() {
    Linking.canOpenURL('geo:37.484847,-122.148386').then(supported => {
        if (supported) {
            Linking.openURL('geo:37.484847,-122.148386');
        } else {
            console.log('Don\'t know how to go');
        }
    }).catch(err => console.error('An error occurred', err));
}

But it keeps giving me 'Don't know how to go'. However, I see from its documentation in https://facebook.github.io/react-native/docs/linking.html that it is doable to use geo: to link to map.

like image 596
Kelvin Aliyanto Avatar asked Mar 13 '16 06:03

Kelvin Aliyanto


1 Answers

Use correct URL scheme

Have a look at the official documentation of iOS. To open maps, use the suggested scheme:

http://maps.apple.com/?ll=<lat>,<long>
like image 68
purii Avatar answered Sep 29 '22 12:09

purii