grst / geos

Google Earth Overlay Server - display map overlays in Google Earth

Home Page:https://grst.github.io/geos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Correct CORS configuration

nono303 opened this issue · comments

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
             })

👍

Would you make that a PR?

there you go! #26