none
Working sample how to use the Imagery Service RRS feed

  • Question

  • Hello,

    I am looking for a working sample for the Imagery Service

    I have used the sample

     

    private string GetImagery(string locationString)

    {

     

    string key = "12356425";

     

    MapUriRequest mapUriRequest = new 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();

     

    string[] digits = locationString.Split(',');

    mapUriRequest.Center.Latitude =

    double.Parse(digits[0].Trim());

    mapUriRequest.Center.Longitude =

    double.Parse(digits[1].Trim());

     

    // Set the map style and zoom level
     

     

    MapUriOptions mapUriOptions = new MapUriOptions();

    mapUriOptions.Style =

    MapStyle.AerialWithLabels;

    mapUriOptions.ZoomLevel = 17;

     

    // Set the size of the requested image in pixels
     

    mapUriOptions.ImageSize =

    new ImageryService.SizeOfint();

    mapUriOptions.ImageSize.Height = 200;

    mapUriOptions.ImageSize.Width = 300;

    mapUriRequest.Options = mapUriOptions;

     

    //Make the request and return the URI
     

    BingMapsSample.ImageryService.

    ImageryService imageryService =

     

    new BingMapsSample.ImageryService.ImageryService();

     

    MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);

     

    return mapUriResponse.Uri;

    }

    This is part of

    http://msdn.microsoft.com/en-us/library/dd221354.aspx

    What have i to enter for the 'key' value?

    I tried and input '47.621, -122.349' in the textbox

    If I press the button I receive an error

    System.Reflection.TargetINvocationException

    {The runtime has refused to evaluate the expression at this time.}

    Anything I have missed?

    Best Regards

    Klaus Sobel

    Microsoft Developer Support EMEA

     

     

     

     

     

     

    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:39 PM (From:Bing Maps: Map Control and Web services Development)
    Friday, May 20, 2011 11:57 AM

Answers

  • Please read the text on the page that you linked to, don't just copy the code sample. It says quite clearly at the top:

    The Bing Maps SOAP Services require that you have a Bing maps key to make requests. You can create a key when you sign into your account at Bing Maps Account Center. For more information about creating a key, see Accessing the Bing Maps Web Services

    And the first line of the code sample reads:

    string key = "insert your Bing Maps key here";

    So I don't know why you arbitrarily inserted the value "12356425"... Bing Maps keys are hexadecimal strings, of about 64 characters in length.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Friday, May 20, 2011 12:43 PM
    Moderator

All replies

  • Please read the text on the page that you linked to, don't just copy the code sample. It says quite clearly at the top:

    The Bing Maps SOAP Services require that you have a Bing maps key to make requests. You can create a key when you sign into your account at Bing Maps Account Center. For more information about creating a key, see Accessing the Bing Maps Web Services

    And the first line of the code sample reads:

    string key = "insert your Bing Maps key here";

    So I don't know why you arbitrarily inserted the value "12356425"... Bing Maps keys are hexadecimal strings, of about 64 characters in length.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Friday, May 20, 2011 12:43 PM
    Moderator
  • Is there any reason why you are using the SOAP services rather than the REST services. The REST services are easier, faster and have more features.
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    Friday, May 20, 2011 5:32 PM