ImageryServiceClient.GetMapUri Method Home
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.

Return Value

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

Example


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;
        
    }

}



   
See Also

Reference

ImageryServiceClient.GetImageryMetadata Method

Concepts

Understanding Tiles

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View