示例#1
0
        public static Task OpenAsync(double latitude, double longitude, MapLaunchOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(Current.OpenMapsAsync(latitude, longitude, options));
        }
示例#2
0
        public static Task OpenAsync(Placemark placemark, MapLaunchOptions options)
        {
            if (placemark == null)
            {
                throw new ArgumentNullException(nameof(placemark));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(Current.OpenMapsAsync(placemark, options));
        }
示例#3
0
        public static Task OpenAsync(Location location, MapLaunchOptions options)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(Current.OpenMapsAsync(location.Latitude, location.Longitude, options));
        }
示例#4
0
文件: Map.uwp.cs 项目: zhamppx97/maui
        internal static Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
        {
            var uri = string.Empty;

            if (options.NavigationMode == NavigationMode.None)
            {
                uri = $"bingmaps:?where={placemark.GetEscapedAddress()}";
            }
            else
            {
                uri = $"bingmaps:?rtp=~adr.{placemark.GetEscapedAddress()}{GetMode(options.NavigationMode)}";
            }

            return(LaunchUri(new Uri(uri)));
        }
示例#5
0
        internal static Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
        {
            Permissions.EnsureDeclared <Permissions.LaunchApp>();

            var appControl = new AppControl
            {
                Operation = AppControlOperations.Pick,
                Uri       = "geo:",
            };

            appControl.Uri += $"0,0?q={placemark.GetEscapedAddress()}";

            AppControl.SendLaunchRequest(appControl);

            return(Task.CompletedTask);
        }
示例#6
0
        internal static Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
        {
            var uri = string.Empty;

            if (options.NavigationMode == NavigationMode.None)
            {
                uri = $"geo:0,0?q={placemark.GetEscapedAddress()}";
                if (!string.IsNullOrWhiteSpace(options.Name))
                {
                    uri += $"({AndroidUri.Encode(options.Name)})";
                }
            }
            else
            {
                uri = $"google.navigation:q={placemark.GetEscapedAddress()}{GetMode(options.NavigationMode)}";
            }

            StartIntent(uri);
            return(Task.CompletedTask);
        }
示例#7
0
        internal static async Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
        {
#if __IOS__
            var address = new MKPlacemarkAddress
            {
                CountryCode = placemark.CountryCode,
                Country     = placemark.CountryName,
                State       = placemark.AdminArea,
                Street      = placemark.Thoroughfare,
                City        = placemark.Locality,
                Zip         = placemark.PostalCode
            }.Dictionary;
#else
            var address = new NSMutableDictionary
            {
                [CNPostalAddressKey.City]           = new NSString(placemark.Locality ?? string.Empty),
                [CNPostalAddressKey.Country]        = new NSString(placemark.CountryName ?? string.Empty),
                [CNPostalAddressKey.State]          = new NSString(placemark.AdminArea ?? string.Empty),
                [CNPostalAddressKey.Street]         = new NSString(placemark.Thoroughfare ?? string.Empty),
                [CNPostalAddressKey.PostalCode]     = new NSString(placemark.PostalCode ?? string.Empty),
                [CNPostalAddressKey.IsoCountryCode] = new NSString(placemark.CountryCode ?? string.Empty)
            };
#endif

            var resolvedPlacemarks = await GetPlacemarksAsync(address);

            if (resolvedPlacemarks?.Length > 0)
            {
                await OpenPlacemark(new MKPlacemark(resolvedPlacemarks[0].Location.Coordinate, address), options);
            }
            else
            {
#if __IOS__ || __MACOS__
                // https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
                var uri   = $"http://maps.apple.com/?q={placemark.GetEscapedAddress()}";
                var nsurl = NSUrl.FromString(uri);

                await Launcher.PlatformOpenAsync(nsurl);
#else
                await OpenPlacemark(new MKPlacemark(default, address), options);
示例#8
0
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapLaunchOptions options)
        {
            var uri = string.Empty;
            var lat = latitude.ToString(CultureInfo.InvariantCulture);
            var lng = longitude.ToString(CultureInfo.InvariantCulture);

            if (options.NavigationMode == NavigationMode.None)
            {
                uri = $"geo:{lat},{lng}?q={lat},{lng}";

                if (!string.IsNullOrWhiteSpace(options.Name))
                {
                    uri += $"({AndroidUri.Encode(options.Name)})";
                }
            }
            else
            {
                uri = $"google.navigation:q={lat},{lng}{GetMode(options.NavigationMode)}";
            }

            StartIntent(uri);
            return(Task.CompletedTask);
        }
 public static Task OpenMapsAsync(this Location location, MapLaunchOptions options) =>
 Map.OpenAsync(location, options);
示例#10
0
文件: Map.uwp.cs 项目: zhamppx97/maui
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapLaunchOptions options)
        {
            var lat  = latitude.ToString(CultureInfo.InvariantCulture);
            var lng  = longitude.ToString(CultureInfo.InvariantCulture);
            var name = options.Name ?? string.Empty;
            var uri  = string.Empty;

            if (options.NavigationMode == NavigationMode.None)
            {
                uri = $"bingmaps:?collection=point.{lat}_{lng}_{name}";
            }
            else
            {
                uri = $"bingmaps:?rtp=~pos.{lat}_{lng}_{name}{GetMode(options.NavigationMode)}";
            }

            return(LaunchUri(new Uri(uri)));
        }
示例#11
0
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapLaunchOptions options)
        {
            Permissions.EnsureDeclared <Permissions.LaunchApp>();

            var appControl = new AppControl
            {
                Operation = AppControlOperations.View,
                Uri       = "geo:",
            };

            appControl.Uri += $"{latitude.ToString(CultureInfo.InvariantCulture)},{longitude.ToString(CultureInfo.InvariantCulture)}";

            AppControl.SendLaunchRequest(appControl);

            return(Task.CompletedTask);
        }
示例#12
0
 /// <include file="../../docs/Microsoft.Maui.Essentials/PlacemarkExtensions.xml" path="//Member[@MemberName='OpenMapsAsync']/Docs" />
 public static Task OpenMapsAsync(this Placemark placemark, MapLaunchOptions options) =>
 Map.OpenAsync(placemark, options);
示例#13
0
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapLaunchOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.Name))
            {
                options.Name = string.Empty;
            }

            NSDictionary dictionary = null;
            var          placemark  = new MKPlacemark(new CLLocationCoordinate2D(latitude, longitude), dictionary);

            return(OpenPlacemark(placemark, options));
        }
示例#14
0
 internal static Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
 => throw ExceptionUtils.NotSupportedOrImplementedException;
示例#15
0
 internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapLaunchOptions options)
 => throw ExceptionUtils.NotSupportedOrImplementedException;