Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for crossOrigin option #2839

Merged
1 commit merged into from Aug 28, 2017

Conversation

ghost
Copy link

@ghost ghost commented Aug 28, 2017

Cross origin is required for forEachLayerAtPixel method, for example. Without that option user gets an error:

intermediatecanvas.js:140 Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
    at ol.renderer.canvas.TileLayer.ol.renderer.canvas.IntermediateCanvas.forEachLayerAtCoordinate (http://localhost:8180/build/ol/renderer/canvas/intermediatecanvas.js:140:44)
    at ol.renderer.canvas.Map.forEachLayerAtPixel (http://localhost:8180/build/ol/renderer/canvas/map.js:207:30)
    at ol.Map.forEachLayerAtPixel (http://localhost:8180/build/ol/map.js:627:25)
    at ol.Map.hoverUnlistenKey_.map.on (http://localhost:8180/common/map/click.js:159:11)
    at ol.Map.boundListener (http://localhost:8180/build/ol/events.js:17:21)
    at ol.Map.ol.events.EventTarget.dispatchEvent (http://localhost:8180/build/ol/events/eventtarget.js:88:24)
    at ol.Map.handleMapBrowserEvent (http://localhost:8180/build/ol/map.js:944:12)
    at ol.MapBrowserEventHandler.boundListener (http://localhost:8180/build/ol/events.js:17:21)
    at ol.MapBrowserEventHandler.ol.events.EventTarget.dispatchEvent (http://localhost:8180/build/ol/events/eventtarget.js:88:24)
    at ol.MapBrowserEventHandler.relayEvent_ (http://localhost:8180/build/ol/mapbrowsereventhandler.js:280:8)

That exception is occurred because of CORS.
Link to OpenLayers doc: https://openlayers.org/en/latest/apidoc/ol.source.WMTS.html

@ghost ghost self-assigned this Aug 28, 2017
@ghost ghost requested review from fredj and gberaudo August 28, 2017 07:16
@ghost ghost merged commit 1a9cee1 into master Aug 28, 2017
@ghost ghost deleted the provide-support-for-swisstopo-cross-origin-option branch August 28, 2017 08:40
@sbrunner sbrunner added this to the 2.3 milestone Apr 12, 2018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants