none
Static Map Return RRS feed

  • Question

  • Hi,

    I'm using the following methods to call for a static map

                                       
     Dim MapBitmap As BitmapImage
    
         Dim poidata AsString

    PublicSub StaticMap(ByVal data AsString)         Dim url AsString = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/?key=" & App.CredKey         Dim wc AsNewWebClient         poidata = data         AddHandler wc.UploadStringCompleted, AddressOf staticMapComplete         'AddHandler wc.OpenWriteCompleted, AddressOf writedatacompleteWith wc             .Headers("Content-Type") = "text/plain; charset=utf-8"             .Encoding = Encoding.UTF8             .UploadStringAsync(NewUri(url, UriKind.Absolute), "POST", data)             '.OpenWriteAsync(New Uri(url, UriKind.Absolute), "POST")EndWithEndSub

                                                               

    PublicSub staticMapComplete(ByVal sender AsObjectByVal e AsUploadStringCompletedEventArgs)         If e.Error IsNothingThenIf e.Result IsNotNothingThen                 MapBitmap.SetSource(NewMemoryStream(Encoding.UTF8.GetBytes(e.Result)))                 RaiseEvent StaticMapReceived("OK")             EndIfRaiseEvent StaticMapReceived("NOMAP")         ElseRaiseEvent StaticMapReceived("ERROR")         EndIfEndSub

    I seem to be receiving data, but it does not render. Can you please provide any assistance ?                                   


    Lee

    Tuesday, June 19, 2012 4:42 PM

Answers

  • So what data are you receiving? If you're supplying an invalid Bing Maps key, for example, then instead of receiving a JPG image as requested you'll get a JSON response containing an element like "

    "errorDetails":["Access was denied. You may have entered your credentials incorrectly, or you might not have access to the requested resource or operation."]

    Which obviously won't render very well if supplied as the image source to a BitmapImage ;)

    Also, what is the value of poidata that you're trying to send in the POST request? If this is badly formatted then that will probably cause the service to not respond with a valid map image either.


    twitter: @alastaira blog: http://alastaira.wordpress.com/


    Friday, June 22, 2012 9:54 AM
    Moderator