Click to Rate and Give Feedback
MSDN
MSDN Library
Online Services
Bing Services
Bing Maps SDKs
 GetMapUri Method
Collapse All/Expand All Collapse All
ImageryServiceClient.GetMapUri Method

Retrieves a URI that can be used to access a static map image.

public MapUriResponse GetMapUri(MapUriRequest request)

Parameters

request
A MapUriRequest object that contains the header and parameter information for the service operation.

Returns a MapUriResponse Class, which contains a URI to a static map image.

C#

private void RequestImage()
{
    try
    {
        // Set a Bing Maps key before making a request
        string key = "Bing Maps Key";
                        
        ImageryService.MapUriRequest mapUriRequest = new ImageryService.MapUriRequest();
        
        // Set credentials using a valid Bing Maps Key
        mapUriRequest.Credentials = new ImageryService.Credentials();
        mapUriRequest.Credentials.ApplicationId  = key;
        
        // Set the location of the requested image
        mapUriRequest.Center = new ImageryService.Location();
        mapUriRequest.Center.Latitude = 47.65;
        mapUriRequest.Center.Longitude = -122.24;

        // Set the map style and zoom level
        ImageryService.MapUriOptions mapUriOptions = new ImageryService.MapUriOptions();
        mapUriOptions.Style = ImageryService.MapStyle.AerialWithLabels;
        mapUriOptions.ZoomLevel = 10;

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

        mapUriRequest.Options = mapUriOptions;
        
        ImageryService.ImageryServiceClient imageryService = new ImageryService.ImageryServiceClient();

       // Make the image request 
        ImageryService.MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);
        string mapUri = mapUriResponse.Uri;
        
        // Set the image control URL to the returned image URI
        Image1.ImageUrl = mapUri;
       
    }
    catch (Exception ex)
    {
        errorLabel.Text = "An exception occurred: " + ex.Message;
        
    }

}



   
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker