예제 #1
0
        static Task OpenPlacemark(MKPlacemark placemark, MapsLaunchOptions options)
        {
            var mapItem = new MKMapItem(placemark)
            {
                Name = options.Name ?? string.Empty
            };

            var mode = MKDirectionsMode.Default;

            switch (options.MapDirectionsMode)
            {
            case MapDirectionsMode.Driving:
                mode = MKDirectionsMode.Driving;
                break;

            case MapDirectionsMode.Transit:
                mode = MKDirectionsMode.Transit;
                break;

            case MapDirectionsMode.Walking:
                mode = MKDirectionsMode.Walking;
                break;
            }

            var launchOptions = new MKLaunchOptions
            {
                DirectionsMode = mode
            };

            var mapItems = new[] { mapItem };

            MKMapItem.OpenMaps(mapItems, launchOptions);
            return(Task.CompletedTask);
        }
예제 #2
0
        internal static Task PlatformOpenMapsAsync(Placemark placemark, MapsLaunchOptions options)
        {
            placemark = placemark.Escape();
            var uri = string.Empty;

            if (options.MapDirectionsMode == MapDirectionsMode.None)
            {
                uri = $"bingmaps:?where=" +
                      $"{placemark.Thoroughfare}" +
                      $"%20{placemark.Locality}" +
                      $"%20{placemark.AdminArea}" +
                      $"%20{placemark.PostalCode}" +
                      $"%20{placemark.CountryName}";
            }
            else
            {
                uri = $"bingmaps:?rtp=~adr." +
                      $"{placemark.Thoroughfare}" +
                      $"%20{placemark.Locality}" +
                      $"%20{placemark.AdminArea}" +
                      $"%20{placemark.PostalCode}" +
                      $"%20{placemark.CountryName}" +
                      $"{GetMode(options.MapDirectionsMode)}";
            }

            return(LaunchUri(new Uri(uri)));
        }
예제 #3
0
        internal static async Task PlatformOpenMapsAsync(Placemark placemark, MapsLaunchOptions options)
        {
            var address = new MKPlacemarkAddress
            {
                CountryCode = placemark.CountryCode,
                Country     = placemark.CountryName,
                State       = placemark.AdminArea,
                Street      = placemark.Thoroughfare,
                City        = placemark.Locality,
                Zip         = placemark.PostalCode
            };

            var coder = new CLGeocoder();

            CLPlacemark[] placemarks = null;
            try
            {
                placemarks = await coder.GeocodeAddressAsync(address.Dictionary);
            }
            catch
            {
                Debug.WriteLine("Unable to get geocode address from address");
                return;
            }

            if ((placemarks?.Length ?? 0) == 0)
            {
                Debug.WriteLine("No locations exist, please check address.");
            }

            await OpenPlacemark(new MKPlacemark(placemarks[0].Location.Coordinate, address), options);
        }
예제 #4
0
        public static Task OpenAsync(double latitude, double longitude, MapsLaunchOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(PlatformOpenMapsAsync(latitude, longitude, options));
        }
예제 #5
0
        internal static Task PlatformOpenMapsAsync(Placemark placemark, MapsLaunchOptions options)
        {
            placemark = placemark.Escape();
            var uri = $"geo:0,0?q={placemark.Thoroughfare} {placemark.Locality} {placemark.AdminArea} {placemark.CountryName}";

            if (!string.IsNullOrWhiteSpace(options.Name))
            {
                uri += $"({options.Name})";
            }
            StartIntent(uri);
            return(Task.CompletedTask);
        }
예제 #6
0
        internal static Task PlatformOpenMapsAsync(Placemark placemark, MapsLaunchOptions options)
        {
            placemark = placemark.Escape();

            var uri = new Uri(
                $"bingmaps:?where=" +
                $"{placemark.Thoroughfare}" +
                $"%20{placemark.Locality}" +
                $"%20{placemark.AdminArea}" +
                $"%20{placemark.CountryName}");

            return(LaunchUri(uri));
        }
예제 #7
0
        public static Task OpenAsync(Location location, MapsLaunchOptions options)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

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

            return(PlatformOpenMapsAsync(location.Latitude, location.Longitude, options));
        }
예제 #8
0
        public static Task OpenAsync(Placemark placemark, MapsLaunchOptions options)
        {
            if (placemark == null)
            {
                throw new ArgumentNullException(nameof(placemark));
            }

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

            return(PlatformOpenMapsAsync(placemark, options));
        }
예제 #9
0
        internal static Task PlatformOpenMapsAsync(Placemark placemark, MapsLaunchOptions options)
        {
            placemark = placemark.Escape();
            var uri = string.Empty;

            if (options.MapDirectionsMode == MapDirectionsMode.None)
            {
                uri = $"geo:0,0?q={placemark.Thoroughfare} {placemark.Locality} {placemark.AdminArea} {placemark.PostalCode} {placemark.CountryName}";
                if (!string.IsNullOrWhiteSpace(options.Name))
                {
                    uri += $"({AndroidUri.Encode(options.Name)})";
                }
            }
            else
            {
                uri = $"google.navigation:q={placemark.Thoroughfare} {placemark.Locality} {placemark.AdminArea} {placemark.PostalCode} {placemark.CountryName}{GetMode(options.MapDirectionsMode)}";
            }

            StartIntent(uri);
            return(Task.CompletedTask);
        }
예제 #10
0
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapsLaunchOptions 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));
        }
예제 #11
0
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapsLaunchOptions options)
        {
            var uri = string.Empty;
            var lat = latitude.ToString(CultureInfo.InvariantCulture);
            var lng = longitude.ToString(CultureInfo.InvariantCulture);

            if (options.MapDirectionsMode == MapDirectionsMode.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.MapDirectionsMode)}";
            }

            StartIntent(uri);
            return(Task.CompletedTask);
        }
예제 #12
0
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapsLaunchOptions 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.MapDirectionsMode == MapDirectionsMode.None)
            {
                uri = $"bingmaps:?collection=point.{lat}_{lng}_{name}";
            }
            else
            {
                uri = $"bingmaps:?rtp=~pos.{lat}_{lng}_{name}{GetMode(options.MapDirectionsMode)}";
            }

            return(LaunchUri(new Uri(uri)));
        }
예제 #13
0
        internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapsLaunchOptions options)
        {
            var uri = string.Empty;

            uri = $"geo:{latitude.ToString(CultureInfo.InvariantCulture)},{longitude.ToString(CultureInfo.InvariantCulture)}?q={latitude.ToString(CultureInfo.InvariantCulture)},{longitude.ToString(CultureInfo.InvariantCulture)}";
            if (!string.IsNullOrWhiteSpace(options.Name))
            {
                uri += $"({options.Name})";
            }
            StartIntent(uri);
            return(Task.CompletedTask);
        }
예제 #14
0
 internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapsLaunchOptions options)
 {
     return(LaunchUri(new Uri(
                          $"bingmaps:?collection=point." +
                          $"{latitude.ToString(CultureInfo.InvariantCulture)}" +
                          $"_" +
                          $"{longitude.ToString(CultureInfo.InvariantCulture)}" +
                          $"_" +
                          $"{options.Name ?? string.Empty}")));
 }
예제 #15
0
 internal static Task PlatformOpenMapsAsync(Placemark placemark, MapsLaunchOptions options)
 => throw new NotImplementedInReferenceAssemblyException();
예제 #16
0
 internal static Task PlatformOpenMapsAsync(double latitude, double longitude, MapsLaunchOptions options)
 => throw new NotImplementedInReferenceAssemblyException();
예제 #17
0
 public static Task OpenMapsAsync(this Placemark placemark, MapsLaunchOptions options) =>
 Maps.OpenAsync(placemark, options);
예제 #18
0
 public static Task OpenMapsAsync(this Location location, MapsLaunchOptions options) =>
 Maps.OpenAsync(location, options);