Correct CORS configuration
nono303 opened this issue · comments
nono303 commented
Hi,
According to https://help.openstreetmap.org/questions/38308/osm-tile-server-how-to-enable-cors, crossOrigin for OL must be null
and not 'anonymous'
to avoid CORS blocking.
Here is the working patch:
diff --git "a/geos/static/custom.js" "b/geos/static/custom.js"
index ab2b30e..85de081 100644
--- "a/geos/static/custom.js"
+++ "b/geos/static/custom.js"
@@ -307,14 +307,15 @@ function activateMap(mapSource) {
currentMap = mapSource;
$('#maps li.active').removeClass('active');
$('#' + mapSource.id).addClass('active');
- console.log(mapSource.name);
+ console.log('loading: '+mapSource.name);
layers = map.getLayers();
layers.clear();
$.each(mapSource.layers, function (i, tileLayer) {
tmpLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
url: tileLayer.tile_url,
- crossOrigin: 'anonymous',
+ // https://help.openstreetmap.org/questions/38308/osm-tile-server-how-to-enable-cors
+ crossOrigin: null,
minZoom: tileLayer.min_zoom,
maxZoom: tileLayer.max_zoom
})
Gregor Sturm commented
👍
Would you make that a PR?