ol-cesium icon indicating copy to clipboard operation
ol-cesium copied to clipboard

crossOrigin setting not passed to images requested by ol-cesium

Open icemagno opened this issue 6 years ago • 3 comments

I'm receiving an obscure message from browser comming from Cesium packed with https://github.com/openlayers/ol-cesium/releases/tag/v1.37

An error occurred in "mf": Failed to obtain image tile X: 4 Y: 2 Level: 3. Cesium.js:459:3692

Was hard to discover its a CORS problem and actually I'm not very happy with this huge limitation because I'm trying to put my 2D map aside and I can't show most of my layers because they come from external Geoservers in WMS format.

Thinking better... The Cesium folder inside OL-Cesium is not yours is it ?

Any way ... Will be nice if you can say something about this:

https://gis.stackexchange.com/questions/282329/ol-cesium-error/282347

Thanks and you can close as soon you read.

icemagno avatar May 09 '18 15:05 icemagno

Sorry @icemagno, I haven't been involved in ol-cesium development in a long time.

The problem here is very likely that Cesium does not request images with img.crossOrigin set to 'anonymous'.

ahocevar avatar May 09 '18 17:05 ahocevar

#581 would fix this, assuming the layer works on the OpenLayers side with the crossOrigin value set. We've opted to extend that class and implement it ourselves, which you can see here (note that it does rely on our custom TilingScheme, so you might need a mix of what is in #581 and the requestImage function from our ImageryProvider).

Even if you do all that, Cesium must have CORS enabled on remote imagery for it to work. Note the crossOrigin value added to the source options from your snippet below.

var layer2 = new ol.layer.Tile({
      source: new ol.source.TileWMS({
        crossOrigin: "anonymous", // or "use-credentials", but not "none"
        url: 'https://demo.boundlessgeo.com/geoserver/wms',
        params: {
          'LAYERS': 'opengeo:countries'
        }
      })
});

wallw-teal avatar Jun 15 '18 22:06 wallw-teal

Also getting cross-origin error on KML example (for the KML file).

tlepkowski avatar Sep 06 '18 14:09 tlepkowski