From b872b5a74f7cd688bf7bde64823bd7b55feda35a Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sat, 27 Oct 2012 09:16:09 +0200 Subject: [PATCH] Cross origin handling to make example work in Firefox The WMS used in the example does not send CORS headers (I think not many WMS services do). It seems that the WebGL renderer needs script access to the image data, so the example only works with the DOM renderer in Firefox. --- examples/wms.js | 4 +++- src/ol/source/tiledwmssource.js | 2 +- src/ol/source/tilesource.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/wms.js b/examples/wms.js index 7f53e21c07..f68fcae9ac 100644 --- a/examples/wms.js +++ b/examples/wms.js @@ -21,13 +21,15 @@ var layers = new ol.Collection([ new ol.layer.TileLayer({ source: new ol.source.TiledWMS({ url: 'http://demo.opengeo.org/geoserver/wms', + crossOrigin: null, params: {'LAYERS': 'topp:states', 'TILED': true} }) }) ]); var map = new ol.Map({ - center: new ol.Coordinate(-10997148, 4569099), + renderer: ol.RendererHint.DOM, layers: layers, target: 'map', + center: new ol.Coordinate(-10997148, 4569099), zoom: 4 }); diff --git a/src/ol/source/tiledwmssource.js b/src/ol/source/tiledwmssource.js index 8ad8e4be12..32353495a7 100644 --- a/src/ol/source/tiledwmssource.js +++ b/src/ol/source/tiledwmssource.js @@ -17,7 +17,7 @@ goog.require('ol.tilegrid.TileGrid'); * @typedef {{attributions: (Array.|undefined), * params: Object, * version: (string|undefined), - * crossOrigin: (string|undefined), + * crossOrigin: (null|string|undefined), * extent: (ol.Extent|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined), * maxZoom: (number|undefined), diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js index bd8293f7d3..9b915efe16 100644 --- a/src/ol/source/tilesource.js +++ b/src/ol/source/tilesource.js @@ -14,7 +14,7 @@ goog.require('ol.tilegrid.TileGrid'); /** * @typedef {{attributions: (Array.|undefined), - * crossOrigin: (string|undefined), + * crossOrigin: (null|string|undefined), * extent: (ol.Extent|undefined), * projection: (ol.Projection|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined),