Windows Phone 8.1 and Windows Runtime Apps How to #18 – Display Bing Map in Windows Phone 8.1

Windows Phone 8.1 SDK provides the Uri scheme called bingmaps: which lets the developers to display a map using the built-in Maps apps from their app.

The bingmaps Uri scheme in Windows Phone 8.1 is the alternative to the MapsTask that was available in Windows Phone 8.

How to display Bing Map in Windows Phone 8.1 ?

To launch the Bing Map in Windows Phone 8.1 using bingmaps: Uri scheme , we must use the Launcher.LaunchUriAsync method.

Below is a sample code snippet demonstrating the use of Geolocator class to get the current location and display it in the Built in Map using the bingmaps: Uri scheme.

async private void Button_Click(object sender, RoutedEventArgs e)
{
    Geolocator geo = new Geolocator();
    Geoposition position = await geo.GetGeopositionAsync();
    string uri = @"bingmaps:?cp=" + position.Coordinate.Point.Position.Latitude + 
           "~" + position.Coordinate.Point.Position.Longitude + "&lvl=17";
    var retValue = await Windows.System.Launcher.LaunchUriAsync(new Uri(uri));

}

In the above code cp attribute is used to indicate that the map is centered around the current location and “lvl” refers to the zoom level.

image

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...