How to open google maps apk via another apk on android or ios in flutter
react-native
.. or any mobile technology. I would like to make a navigation system in my application so I want to directly use google maps through my application. Can someone help me please?
CodePudding user response:
To open Google Maps app from your app you could do something like this.
First set up your url String (what you will send to Google maps app so it knows what directions give):
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);
Where currentLocation means the user current location, and lat and lon means the destination.
Then just launch that url, using an urlLauncher:
void _launchURL(String url) async { if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } }