简体   繁体   中英

How To render the directions when Linking Google maps App in react native?

I want to render the directions between tow point (current location, passed location)

I'm using Linking to open the Google Maps App when clicking the button I passed the (lat, long), I want to see in the map.

so just when the Maps App open they get me to the Location I passed without display the destination between my current location and other address and without any Markers, any idea how to solve these?

地图

Here is my Code

_openMap = () => {
        const { region } = this.state;
        console.log('open directions');
        // Linking.openURL('geo:37.484847,-122.148386');
        Linking.canOpenURL(`geo:${region.latitude},${region.longitude}`).then(supported => {
            if (supported) {
                Linking.openURL(`geo:${region.latitude},${region.longitude}`);
            } else {
                alert('sorry invalid url')
            }
        });
    }

Use either:

google.navigation:q=a+street+address

or

google.navigation:q=latitude,longitude

Source: https://developers.google.com/maps/documentation/urls/android-intents#launch_turn-by-turn_navigation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM