如何在flutter react-native .. 或任何移動技術中通過另一個 apk 在 android 或 ios 上打開谷歌地圖 apk 。我想在我的應用程式中制作一個導航系統,所以我想通過我的應用程式直接使用谷歌地圖。有人能幫助我嗎?
uj5u.com熱心網友回復:
要從您的應用程式打開 Google 地圖應用程式,您可以執行以下操作。
首先設定您的 url 字串(您將發送到 Google 地圖應用程式的內容,以便它知道給出的方向):
String url = 'https://www.google.com/maps/dir/?api=1&origin=' currentLocation.latitude.toString() ',' currentLocation.longitude.toString() ' &destination=' lat.toString() ',' lon.toString() '&travelmode=driving&dir_action=navigate'; _launchURL(url);
其中 currentLocation 表示用戶當前位置,lat 和 lon 表示目的地。
然后使用 urlLauncher 啟動該 url:
void _launchURL(String url) async { if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } }
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/347854.html
