Igor-Vladyka / leaflet.browser.print

A leaflet plugin which allows users to print the map directly from the browser
https://igor-vladyka.github.io/leaflet.browser.print/
MIT License
155 stars 76 forks source link

[Geotiff] Geotiff file on print #127

Open mateuszbem opened 1 year ago

mateuszbem commented 1 year ago

Have you ever tried priting *.tiff files (layerGroup)?

I'm using https://github.com/GeoTIFF/georaster-layer-for-leaflet for showing .tiff files on map, but when it comes to printing it doesn't show. image and the effect: image

Igor-Vladyka commented 1 year ago

Do you register it properly? Can you provide a code example with a registration of this layer?

mateuszbem commented 1 year ago

It is in ngAfterViewInit(), I tried multiple solutions, everytime with no effect.

this.layerGroup = L.layerGroup().addTo(this.map);
this.browserPrint = L.control.browserPrint({
  title: 'Geotiff test',
}).addTo(this.map);
L.BrowserPrint.Utils.registerLayer(
  L.LayerGroup,
  'L.LayerGroup',
  function(layer, utils) {
    const cluster: LayerGroup = L.layerGroup(layer._group.options);
    cluster.addLayer(utils.cloneInnerLayers(layer._group));
    return cluster;
  });

@edit In structure it is canvas image

Igor-Vladyka commented 1 year ago

L.LayerGroup is already in the list, you need to register actual layer that is missing => GeoRasterLayer try

L.BrowserPrint.Utils.registerLayer(
  GeoRasterLayer,
  'GeoRasterLayer',
  function(layer, utils) {
    const cluster: GeoRasterLayer = GeoRasterLayer(layer._group.options);
    cluster.addLayer(utils.cloneInnerLayers(layer._group));
    return cluster;
  });

or something like that, you would need to debug/check what exactly to pass inside function.

mateuszbem commented 1 year ago

Thank you Igor, it works.

L.BrowserPrint.Utils.registerLayer(
  GeoRasterLayer,
  'GeoRasterLayer',
  function(layer: any) {
    const options: GeoRasterLayerOptions = {
      georaster: layer.options.georaster,
      opacity: 0.6,
      resolution: 128,
    };
    const cluster: Layer = new GeoRasterLayer(options);
    return cluster;
  });
Falke-Design commented 1 year ago

Following worked for me:

L.BrowserPrint.Utils.registerLayer(
        GeoRasterLayer,
    'GeoRasterLayer',
    function(layer) {
            return new GeoRasterLayer(layer.options);
    });