Esempio n. 1
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)));
        }
Esempio n. 2
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);
        }
Esempio 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);
        }
        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);