none
BING maps cross-domain (CORS) RRS feed

  • Question

  • Hello,

        I am using the Bing map rest api to get a static map. Currently I am building the url and is setting the img src to the url like so

       
     $(".map").attr("src",  "https://dev.virtualearth.net/REST/v1/Imagery/Map/"+mapImagery+"/" + lat + "," + long + "/"+zoomLvl+"?pp=" + lat + "," + long + ";64&key=" + store("bingMapSessionId"));

    The above method works fine. What I would like to do is that instead of setting the url directly, I want to use the jquery ajax to create the url and pass the data in like this

     $.ajax({
             url: "https://dev.virtualearth.net/REST/v1/Imagery/Map/" + mapImagery + "/" + lat + "," + long + "/" + zoomLvl,
             data: {                                                      
                    pushpin: lat + "," + long + ";64",
                    key: store("bingMapSessionId")
                    },
              success: function (data) {
                     $(".map").attr("src", "the img return");
              },
              error: function (e) {
                      window.console && console.log(e);
               }
    });

    The problem is that I am getting a  XMLHttpRequest .... required Cross Origin Resource Sharing (CORS).

    and the error Origin https//:...net not found in Access-Control-Allow-Origin header. I was wondering if the bing map tile are served with CORS permission? Or is there an alternative to getting the map with out directly setting the src to the url. I am fully aware of the AJAX map control that is available, but that counts as a billable transaction every time the control loads, and I did not require the interactivity, just the static map.

    Monday, August 18, 2014 11:43 PM

Answers