简体   繁体   中英

Expo React Native WebView opens google maps in app on Android

I have an app that is made of a <webView> and displays some buttons that open different Google Maps links.

On iOS the link opens in the Maps app but on Android it opens in the same view (baiscally in the app).

When I press the "Start Navigation" button from Google I get an error related to intent://google-maps-link

Beggining of error looks like:

Can't open url: intent://maps.app.goo.gl/?link

I pass that link to the view in a <a> tag like this:

<a class="btn btn-info" href="<?php echo $lm['TextLink'] ?>" target="_blank">Start Route</a>

How can I open the link in a new browser (that is installed on the Android phone) or directly in the google maps app ?

I have been searching for more than 2 days but same behaviour occurs.

Thanks in advance!

You'll have to use expo-linking for this. It should resolve the intent error for you. Just use something like this in your onPress function-

Linking.openURL('http://maps.google.com/?q=100+Main+Street+Buffalo+NY');

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