How to manage maps in Windows 8 without a native control

If you want to show a map with a pushpin in Metro app you need, up to now, to embed the Map into a WebView control to avoid the lack of a native Map Control in Windows 8.

To generate a valid URL from latitude and longitude parameters use this method in your code

public static string GetMapUri(double latitude, double longitude, int zoom, string mapStyle, int width, int height)
ObservableCollection pins = new ObservableCollection();

ImageryService.Pushpin pushpin = new ImageryService.Pushpin();
pushpin.Location = new ImageryService.Location();
pushpin.Location.Latitude = latitude;
pushpin.Location.Longitude = longitude;
pushpin.IconStyle = "2";


MapUriRequest mapUriRequest = new MapUriRequest();

// Set credentials using a valid Bing Maps Key
mapUriRequest.Credentials = new ImageryService.Credentials();
mapUriRequest.Credentials.ApplicationId = BingMapKey; // use your personal key

// Set the location of the requested image
mapUriRequest.Pushpins = pins;

// Set the map style and zoom level
MapUriOptions mapUriOptions = new MapUriOptions();

switch (mapStyle.ToUpper())
case "HYBRID":
mapUriOptions.Style = ImageryService.MapStyle.AerialWithLabels;
case "ROAD":
mapUriOptions.Style = ImageryService.MapStyle.Road;
case "AERIAL":
mapUriOptions.Style = ImageryService.MapStyle.Aerial;
mapUriOptions.Style = ImageryService.MapStyle.Road;

mapUriOptions.ZoomLevel = zoom;

// Set the size of the requested image to match the size of the image control
mapUriOptions.ImageSize = new ImageryService.SizeOfint();
mapUriOptions.ImageSize.Height = height;
mapUriOptions.ImageSize.Width = width;

mapUriRequest.Options = mapUriOptions;

ImageryServiceClient imageryService = new ImageryServiceClient(ImageryServiceClient.EndpointConfiguration.BasicHttpBinding_IImageryService);
MapUriResponse mapUriResponse = null;
mapUriResponse = imageryService.GetMapUriAsync(mapUriRequest).Result;
catch (Exception ex)
Debug.WriteLine("GeoLocation: " + ex.Message);

return mapUriResponse.Uri;

You also need to reference the Bing Maps SOAP Services




Wrap the generated string in a URI and insert it into the WebView controller.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s