123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:url_launcher/url_launcher.dart';
- class MapNavigatorUtil {
-
- static Future<bool> gotoAppleMapByKeywords({keywords,longitude, latitude ,required VoidCallback toInstallCallBack}) {
- var url = 'http://maps.apple.com/?&daddr=${Uri.encodeComponent(keywords)}';
- return gotoMap(url: url, toInstallCallBack: () {
- if (null != toInstallCallBack) {
- toInstallCallBack();
- }
- });
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
- static Future<bool> gotoAppleMap({longitude, latitude ,required VoidCallback toInstallCallBack}) {
- var url = 'http://maps.apple.com/?&daddr=$latitude,$longitude';
- return gotoMap(url: url, toInstallCallBack: () {
- if (null != toInstallCallBack) {
- toInstallCallBack();
- }
- });
-
-
-
-
-
-
- }
-
- static Future<bool> gotoAMap(
- {longitude, latitude, address, required VoidCallback toInstallCallBack}) {
- var url =
-
- '${Platform.isAndroid ? 'android' : 'ios'}amap://viewMap?sourceApplication=amap&poiname=${address}&lat=$latitude&lon=$longitude&dev=0';
-
- return gotoMap(
- url: url,
- toInstallCallBack: () {
- if (null != toInstallCallBack) {
- toInstallCallBack();
- }
- });
- }
-
- static Future<bool> gotoTencentMap(
- {longitude, latitude,address, required VoidCallback toInstallCallBack}) async {
- var url =
-
-
-
- 'qqmap://map/marker?marker=coord:$latitude,$longitude;title:${address};addr:${address}&referer=BVWBZ-DBB3J-NZGFF-XUKHP-DTDQK-2BFLN';
-
- return gotoMap(
- url: url,
- toInstallCallBack: () {
- if (null != toInstallCallBack) {
- toInstallCallBack();
- }
- });
- }
-
- static Future<bool> gotoBaiduMap(
- {longitude, latitude,address, required VoidCallback toInstallCallBack}) async {
- var url =
-
-
-
- 'baidumap://map/marker?location=$latitude,$longitude&title=${address}&coord_type=gcj02&src=${Platform.isAndroid ? 'andr' : 'ios'}.baidu.openAPIdemo';
-
- return gotoMap(
- url: url,
- toInstallCallBack: () {
- if (null != toInstallCallBack) {
- toInstallCallBack();
- }
- });
- }
-
-
-
- static Future<bool> gotoMap(
- {required String url, required VoidCallback toInstallCallBack}) async {
- bool canLaunchUrl = await isMapInstall(url);
- if (!canLaunchUrl) {
- if (null != toInstallCallBack) {
- toInstallCallBack();
- }
- return false;
- }
- await launch(url);
- return true;
- }
- static void toInstallMap(String url) {
- launch(url);
- }
- static Future<bool> isBaiduMapInstall() {
- return canLaunch('baidumap://map/direction');
- }
- static Future<bool> isTencentMapInstall() {
- return canLaunch('qqmap://map/routeplan');
- }
- static Future<bool> isAmapMapInstall() {
- return canLaunch('${Platform.isAndroid ? 'android' : 'ios'}amap://navi');
- }
- static Future<bool> isIOSAmapMapInstall() async {
-
- var url = 'http://maps.apple.com/?&daddr=30.617915,114.255173';
- bool canLaunchUrl = await canLaunch(url);
- return canLaunchUrl;
- }
-
- static Future<bool> isMapInstall(String url) {
- return canLaunch(url);
- }
- }
|