rowanwins / leaflet-easyPrint

A leaflet plugin which adds an icon to print the map - Demo @ http://rowanwins.github.io/leaflet-easyPrint/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is that possible to print current map in 300 dpi.?

mackspidy opened this issue · comments

Hi,

I have to print my current map into 300 dpi so I can pint with big size or resolution in the same state.?

Did you figure this out? @mackspidy

@mackspidy can you be more precise please ? Where to resize it ?

Any progress on this?

Here is an ugly work around that I use for a programmatically screenshot trigger.

  1. It oversize the map.
  2. Place a leaflet layer in the middle of the map.
  3. Take the screenshot.
  4. Reset the old map size.
const width_target = 1920, height_target = 1920;

const printPlugin = L.easyPrint({
    exportOnly : true,
    hidden : true,
}).addTo(map);

$('#btn_export').click(function (){
    let printed = false;

    const $divMap = $('#divMap');
    const old_width = $divMap.width(), old_height = $divMap.height();

    $divMap.animate({'width' : width_target, 'height' : height_target},() => {
        map.invalidateSize();
        
        map.fitBounds(myLeafletLayerToFocus);

        map.on('moveend', ()=>{
            if (printed) return false;

            map.on('easyPrint-start', ()=>{
                printed = true;
            });

            map.on('easyPrint-finished', ()=>{
                $divMap.width(old_width);
                $divMap.height(old_height);
                
                map.fitBounds(myLeafletLayerToFocus);
                map.invalidateSize();
            });

            // *******************************************************
            printPlugin.printMap('CurrentSize', 'fileName');
            // *******************************************************
        });
    });
});