Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
Ejemplo n.º 6
0
 public static Task OpenAsync(Placemark placemark) =>
 OpenAsync(placemark, new MapLaunchOptions());
Ejemplo n.º 7
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);
Ejemplo n.º 8
0
 /// <include file="../../docs/Microsoft.Maui.Essentials/PlacemarkExtensions.xml" path="//Member[@MemberName='OpenMapsAsync']/Docs" />
 public static Task OpenMapsAsync(this Placemark placemark) =>
 Map.OpenAsync(placemark);
Ejemplo n.º 9
0
 internal static Task PlatformOpenMapsAsync(Placemark placemark, MapLaunchOptions options)
 => throw ExceptionUtils.NotSupportedOrImplementedException;