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 = "" & 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 ?                                   


    Tuesday, June 19, 2012 4:42 PM


  • 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:

    Friday, June 22, 2012 9:54 AM