diff --git a/lib/widgets/hospital_location.dart b/lib/widgets/hospital_location.dart index 8ba7b4bd..780aa32e 100644 --- a/lib/widgets/hospital_location.dart +++ b/lib/widgets/hospital_location.dart @@ -8,6 +8,7 @@ import 'package:url_launcher/url_launcher.dart'; import 'avatar/large_avatar.dart'; import 'my_rich_text.dart'; +import 'dart:io' show Platform; class HospitalLocation extends StatelessWidget { final GetHMGLocationsModel location; @@ -74,7 +75,9 @@ class HospitalLocation extends StatelessWidget { Column( children: [ contactButton(Icons.location_on, TranslationBase.of(context).locationa, () { - MapsLauncher.launchCoordinates(double.parse(location.latitude), double.parse(location.longitude), location.locationName); + // MapsLauncher.launchCoordinates(double.parse(location.latitude), double.parse(location.longitude), location.locationName); + // launchMap( double.parse(location.latitude), double.parse(location.longitude)); + navigateTo(double.parse(location.latitude), double.parse(location.longitude)); }), SizedBox(height: 10), contactButton(Icons.call, TranslationBase.of(context).callNow, () { @@ -107,4 +110,39 @@ class HospitalLocation extends StatelessWidget { ), ); } + + static void navigateTo(double latitude, double longitude) async { + var uri = Uri.parse("google.navigation:q=$latitude,$longitude&mode=d"); + if (await canLaunch(uri.toString())) { + await launch(uri.toString()); + } else { + throw 'Could not launch ${uri.toString()}'; + } + } + +// launchMap(latitude, longitude) async { +// var url = ''; +// var urlAppleMaps = ''; +// if (Platform.isAndroid) { +// url = "https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}"; +// } else { +// urlAppleMaps = 'https://maps.apple.com/?q=$latitude,$longitude'; +// url = "comgooglemaps://?saddr=&daddr=$latitude,$longitude&directionsmode=driving"; +// if (await canLaunch(url)) { +// await launch(url); +// } else { +// throw 'Could not launch $url'; +// } +// } +// +// if (await canLaunch(url)) { +// await launch(url); +// } else if (await canLaunch(urlAppleMaps)) { +// await launch(urlAppleMaps); +// } else { +// throw 'Could not launch $url'; +// } +// } + + }