1. A concise explanation of the problem you’re experiencing.
I am calling “Cesium.loadJson”, in order to reach a virtualearth url…
I understand that if I don’t define a custom header, Cesium will append the default header: headers = {Accept: “application/json,/;q=0.01”}
51
This sounds to me like a way to communicate with the Bing Maps REST service, which I understand does not support CORS.
However, I do not get any result...
This is what I get in the console...kinda confusing :)
Failed to load https://dev.virtualearth.net/REST/v1/Locations/36.19241768243102,-108.36173979199924?format=json&key=<MY KEY>: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
HelloWorld.html:44 **Error is Request has failed.**
Cesium.js:489
XHR finished loading: GET "https://dev.virtualearth.net/REST/v1/Locations/36.19241768243102,-108.36173979199924?format=json&key=<MY KEY>".
So did it load or not? Obviously I am not getting any result, so it must have failed...
Am I doing something wrong, or forgetting something? I am not a JS expert, so any advice will be welcome.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
var requestString = ‘https://dev.virtualearth.net/REST/v1/Locations/’ + latitude + ‘,’ + longitude + ‘?format=json&key=’;
Cesium.loadJson(requestString).then(function(results) {
console.log(results);
}).otherwise(function(error) {
console.log('Error is ’ + error);
});
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I am writing a reverse geocoder, using Bing Maps.
I am sending latitude and longitude, and expecting a JSON result. This works fine, if loaded in https://robwu.nl/cors-anywhere.html for demonstration purposes.
4. The Cesium version you’re using, your operating system and browser.
Cesium 1.38 on Mac, with Chrome.