MSDN Library

ImageryServiceClient.GetMapUri Method

 

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

public MapUriResponse GetMapUri(MapUriRequest request)

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.

private void RequestImage()
 {
 string Results="";
 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_v1;
 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 = 400;
 mapUriOptions.ImageSize.Width = 600;

 mapUriRequest.Options = mapUriOptions;

 ImageryService.ImageryServiceClient imageryService =
   new ImageryService.ImageryServiceClient("BasicHttpBinding_IImageryService");

 // Make the image request
 ImageryService.MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);
 string mapUri = mapUriResponse.Uri;

 // Set the image control URL to the returned image URI
 Results = mapUri;

 }
 catch (Exception ex)
 {
 Results = "An exception occurred: " + ex.Message;

 }

 }



Private Sub RequestImage()
Dim Results As String
Try
' Set a Bing Maps key before making a request

Dim key = "Bing Maps Key"

Dim mapUriRequest As New ImageryService.MapUriRequest()

' Set credentials using a valid Bing Maps Key
mapUriRequest.Credentials = _
New ImageryService.Credentials() With {.ApplicationId = key}

' Set the location of the requested image
mapUriRequest.Center = _
New ImageryService.Location() With {.Latitude = 47.65, .Longitude = -122.24}

' Set the map style and zoom level
Dim mapUriOptions As New ImageryService.MapUriOptions() _
With {.Style = imageryService.MapStyle.AerialWithLabels_v1, .ZoomLevel = 10}

' Set the size of the requested image to match the size of the image control
mapUriOptions.ImageSize = New ImageryService.SizeOfint() _
With {.Height = 400, .Width = 600}

mapUriRequest.Options = mapUriOptions

Dim ImageryServiceInstance As New 
  ImageryService.ImageryServiceClient("BasicHttpBinding_IImageryService")

' Make the image request
Dim mapUriResponse = ImageryServiceInstance.GetMapUri(mapUriRequest)
Dim mapUri = mapUriResponse.Uri

' Set the image control URL to the returned image URI
Results = mapUri

Catch ex As Exception
Results = "An exception occurred: " & ex.Message
End Try

End Sub
Show:
© 2016 Microsoft