I want to create a client side printing module for OpenLayers (v6) map. In OpenLayers web site there is a printing example with JSPDF (Export PDF example ). I used this example but there is an error:
In firefox:
SecurityError: The operation is insecure.
In Chrome:
SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
and error is on this line:
mapCanvas.toDataURL('image/jpeg'), 'JPEG', 0, 0, dim[0], dim[1])
My Problem is that when I add Vector Tile Layers (not WMS, not vector layer, not OSM Tiles) with MVT() format, layers are shown but after using print module, this error is showing in console.
I used crossOrigin: 'anonymous'
like this answer for my vector tile source but the mentioned error there is on console and it is not working truly:
new VectorTileSource({
crossOrigin: "Anonymous",
format: new MVT({
idProperty: "id"
}),
renderMode:"hybrid",
defaultDataProjection: "EPSG:900913",
url: GEOSERVER_ADDDRESS+"gwc/service/tms/1.0.0/" + STORE+":"+LAYER_NAME +
"@EPSG%3A"+"900913"+"@pbf/{z}/{x}/{-y}.pbf"
})
My GeoServer is running on port 8080 and is not installed on Tomcat. Is there any solution for this issue on client side (OpenLayers) or server side (GeoServer)?
I couldn't find any solution for my case and I don't know how should I probably config GeoServer to solve this problem.
crossOrigin: 'anonymous'
in the icon style as in openlayers.org/en/latest/examples/icon-negative.html or you could copy the file to you own server,