grinat / leaflet-simple-map-screenshoter

Leaflet plugin which take screenshot of map
MIT License
71 stars 19 forks source link

cannot add WMS layer #15

Open silv2015 opened 3 years ago

silv2015 commented 3 years ago

Hi and Thanks for this great project!

I have a problem with the capture is when I add the WMS layer, I don't see it on the image but empty tiles, it shoes correctly on the map.

image

not sure what I did wrong? I would appreciate any help! Thanks!

This is my configuration...

    this._printPlugin = L.simpleMapScreenshoter({
        cropImageByInnerWH: true,
        hidden: false,
        preventDownload: true,
        domtoimageOptions: {},
        screenName: 'mapZ',
        hideElementsWithSelectors: ['.leaflet-control-container'],
        mimeType: 'image/png',
        caption: null
    }).addTo(this._mapZ)
haayman-imagem commented 2 years ago

It seems that there's a security issue with the canvas when there are external WMS services in the map. I also get an error message 'Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.' when I've got WMS services loaded from a different source than the site

waystilos commented 2 years ago

This is a little late but this fixed the CORS issues for me.

    domtoimageOptions: {
      crossOrigin: 'anonymous',
    }