From 7ffb4314545f437155aa41eeae58c635cdafea55 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 2 Dec 2021 11:59:33 +0300 Subject: [PATCH] added map luncher --- ios/Runner/Info.plist | 16 +++++++ .../product-details/availability_info.dart | 10 ++++- lib/widgets/hospital_location.dart | 42 ++++--------------- pubspec.yaml | 1 + 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index ec89ac71..02eb80d9 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -96,3 +96,19 @@ + +LSApplicationQueriesSchemes + + comgooglemaps + baidumap + iosamap + waze + yandexmaps + yandexnavi + citymapper + mapswithme + osmandmaps + dgis + qqmap + here-location + diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index a5ba0956..08c6d5de 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:map_launcher/map_launcher.dart'; class AvailabilityInfo extends StatelessWidget { final ProductDetailViewModel previousModel; @@ -54,7 +55,14 @@ class AvailabilityInfo extends StatelessWidget { icon: Icon(Icons.location_on), color: Colors.red, onPressed: () { - MapsLauncher.launchCoordinates(double.parse(previousModel.productLocationService[index].latitude), double.parse(previousModel.productLocationService[index].longitude), previousModel.productLocationService[index].locationDescription); + MapLauncher.showMarker( + mapType: MapType.google, + coords: Coords(double.parse(previousModel.productLocationService[index].latitude), + double.parse(previousModel.productLocationService[index].longitude)), + title: previousModel.productLocationService[index].locationDescription, +// description: location.locationName, + ); + // MapsLauncher.launchCoordinates(double.parse(previousModel.productLocationService[index].latitude), double.parse(previousModel.productLocationService[index].longitude), previousModel.productLocationService[index].locationDescription); }, ), ), diff --git a/lib/widgets/hospital_location.dart b/lib/widgets/hospital_location.dart index 780aa32e..e9395906 100644 --- a/lib/widgets/hospital_location.dart +++ b/lib/widgets/hospital_location.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:map_launcher/map_launcher.dart'; import 'avatar/large_avatar.dart'; import 'my_rich_text.dart'; @@ -15,6 +16,7 @@ class HospitalLocation extends StatelessWidget { final bool showCity; final String waitingTime; + HospitalLocation(this.location, {Key key, this.showCity = false, this.waitingTime}) : super(key: key); @override @@ -76,8 +78,12 @@ class HospitalLocation extends StatelessWidget { children: [ contactButton(Icons.location_on, TranslationBase.of(context).locationa, () { // 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)); + MapLauncher.showMarker( + mapType: MapType.google, + coords: Coords(double.parse(location.latitude), double.parse(location.longitude)), + title: location.locationName, +// description: location.locationName, + ); }), SizedBox(height: 10), contactButton(Icons.call, TranslationBase.of(context).callNow, () { @@ -111,38 +117,6 @@ 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'; -// } -// } } diff --git a/pubspec.yaml b/pubspec.yaml index ff6873fc..5b1b0a1f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -143,6 +143,7 @@ dependencies: #google maps places google_maps_place_picker: ^1.0.0 + map_launcher: ^1.1.3 #countdown timer for Upcoming List flutter_countdown_timer: ^1.6.0