Example #1
0
        static Task DoLaunchDirections(NavigationAddress destination)
        {
            var url = $"{BASE_URL}{ToUrl(destination)}";

            if (Attempt(url, "com.google.android.apps.maps", "com.google.android.maps.MapsActivity"))
            {
                return(Task.CompletedTask);
            }

            if (Attempt(url))
            {
                return(Task.CompletedTask);
            }

            if (destination.HasGeoLocation())
            {
                url = "geo:{0},{1}?q={0},{1}{2}".FormatWith(
                    destination.Latitude, destination.Longitude, destination.Name.WithWrappers("(", ")"));
            }
            else
            {
                url = "geo:0,0?q=" + destination.GetAddressParts().ToString(" ");
            }

            if (Attempt(url))
            {
                return(Task.CompletedTask);
            }

            throw new Exception(" There is no recognized map application.");
        }
Example #2
0
 static string ToUrl(NavigationAddress address)
 {
     if (address.HasGeoLocation())
     {
         return($"{address.Latitude},{address.Longitude}{address.Name.WithWrappers(" (", ")")}");
     }
     else
     {
         var addr     = address.GetAddressParts();
         var location = GetLocationFromAddress(addr.ToString(","));
         return(location.Latitude + "," + location.Longitude);
     }
 }
Example #3
0
        static async Task DoLaunchDirections(NavigationAddress destination)
        {
            string query;

            if (destination.HasGeoLocation())
            {
                query = $"collection=point.{destination.Latitude}_{destination.Longitude}_{destination.Name}";
            }
            else
            {
                query = "where=" + destination.GetAddressParts().Select(x => x).ToString(",");
            }

            var successful = await Windows.System.Launcher.LaunchUriAsync(new Uri("bingmaps:?" + query));

            if (!successful)
            {
                throw new Exception("Failed to launch BingMaps");
            }
        }