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
154 stars 76 forks source link

How to add Custom Logo image and custom attribute text while printing #109

Closed CityBelfast closed 2 years ago

CityBelfast commented 2 years ago

Hi, I'm using a custom logo image and custom attribute text on the map. But when I print this map using leaflet.browser.print library those details are missing. image

Actual Logo image

So, would you please give some idea about how to add custom image logo and custom attribute while printing map?

see the below printing code

L.control.browserPrint({ position: 'topright', closePopupsOnPrint: true, printModes: [ L.control.browserPrint.mode.landscape(), L.control.browserPrint.mode.portrait() ], manualMode: false }).addTo(map);

         map.on(L.Control.BrowserPrint.Event.PrePrint, function (mode) {
            debugger;
            map.attributionControl.addAttribution('<a target="_blank" class="non-active">Copyright OS 2021</a>');
            $("div.leaflet-control-attribution a:not(:last)").remove();
            $("div.leaflet-control-attribution").contents().filter(function () { return this.nodeType === 3 }).remove();
        });
Igor-Vladyka commented 2 years ago

Hey there.

When printing we create basically a new map, so your logo is missing on it. You need to add it one more time for each print.

map.on("browser-print-start", function(e){
    /*Add same code for a logo here, and it will work*/
});
CityBelfast commented 2 years ago

Thanks