Closed nono303 closed 4 years ago
Hi,
According to https://help.openstreetmap.org/questions/38308/osm-tile-server-how-to-enable-cors, crossOrigin for OL must be nulland not 'anonymous' to avoid CORS blocking.
null
'anonymous'
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 })
:+1:
Would you make that a PR?
there you go! https://github.com/grst/geos/pull/26
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: