Further cors problems.

Cosider this code:

<div id="cesiumContainer1" width = "98%" style = "border: 2px solid white;" padding = "4px" margin = "4px">
</div>
<style>@import url(../Cesium/Build/Cesium/Widgets/widgets.css);</style>

<script src="../Cesium/Build/Cesium/Cesium.js"></script>

<script type = "text/javascript">
var div1 = document.createElement('div');
var t1 = document.getElementById('outcell');
t1.appendChild(div1);
div1.id = 'cesiumContainer1';
div1.style.width = '98%';
div1.style.border = '2px solid white'; // this is what constructs the div above
</script>

<script type = "text/javascript">
var map1 = new Cesium.CesiumWidget('cesiumContainer1', {
         sceneMode : Cesium.SceneMode.SCENE3D
         });
var scene1 = map1.scene;
var terrainProvider1 = new Cesium.CesiumTerrainProvider({
      url : '//cesiumjs.org/tilesets/terrain/smallterrain'
        });
        scene1.terrainProvider = terrainProvider1;
scene1.camera.viewRectangle(Cesium.Rectangle.fromDegrees(-87,24,-80,31)); // look at florida
</script>

Now, I pan to the islands of cuba near Florida, zoom in, then tilt the map, to see the terrain. This is working.

Now I add this :

var layers = scene1.globe.imageryLayers;
    layers.removeAll();
    layers.addImageryProvider(new Cesium.ArcGisMapServerImageryProvider({
        url : ‘http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer’,
    }));

Thus, I have :

<script type = “text/javascript”>
var map1 = new Cesium.CesiumWidget(‘cesiumContainer1’, {
         sceneMode : Cesium.SceneMode.SCENE3D
         });
var scene1 = map1.scene;
var terrainProvider1 = new Cesium.CesiumTerrainProvider({
      url : ‘//cesiumjs.org/tilesets/terrain/smallterrain
        });
        scene1.terrainProvider = terrainProvider1;
var layers = scene1.globe.imageryLayers;
layers.removeAll();
layers.addImageryProvider(new Cesium.ArcGisMapServerImageryProvider({
        url : ‘http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer’,
    }));

scene1.camera.viewRectangle(Cesium.Rectangle.fromDegrees(-87,24,-80,31)); // look at florida
</script>

Do the same tilting, and I get a Cors error. I realize that ESRI does not provide proper CORS headers. Any workaround? I am using my own localhost / AWS server

Hi,

I believe that Esri’s public servers do in fact include proper CORS headers these days. I pasted your code into Sandcastle and it worked fine for me. No errors, CORS-related or otherwise, and the Esri imagery appeared.

Exactly what error are you seeing?

Kevin

Hi, the imagery is fine, as long as you dont tilt and zoom / pan the 3D view.

If you do so, Cesium crashes, with the error in konsole : XMLHttpRequest cannot load ... disallowed for cross-origin (Firefox, Linux)

Sorry, I’m not seeing that. I even tried Firefox on Linux. A CORS failure like that shouldn’t crash Cesium in any case. Exactly what do you mean by “Cesium crashes”?

Exactly what do you mean by "Cesium crashes"?

The rendering canvas (the webGL viewport) disappears from the HTML document body -- and then firefox redirects itself to a random location / page, often one that is open in another tab.

That sounds very sketchy. It’s hard for me to imagine what Cesium could be doing to cause that.

I will make a video or a screengrab if that helps.