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

Browser-print + Plugin leaflet-graphicscale #101

Closed klaupher closed 3 years ago

klaupher commented 3 years ago

Hi!!

Please, I need your help!!! The printing of my maps must have the scale. Even after inserting this scale in the map by the event "browse-print-start", the css of the scales are not "sent" for printing. As a result, the scale appears, but without any style. This makes it very difficult to visualize the information. Do you have any idea how to do this ??

image

klaupher commented 3 years ago

completing..

this is my code out print:

L.control.graphicScale({
    fill: 'hollow',
    imperial: false,
    position: 'bottomleft',
    doubleLine: true,
    maxUnitWidth: 100,
}).addTo(map);

and this is my browser-print-start event:

map.on("browser-print-start", function (e) {
    L.control.graphicScale({
        fill: 'hollow',
        metric: true,
        imperial: false,
        position: 'bottomleft',
        labelPlacement: 'bottom'
    }).addTo(e.printMap);

});

thanks..

klaupher commented 3 years ago

Hi.. I modified my browser-print-start event and works fine!!!

map.on("browser-print-start", function (e) {
    var header = document.querySelector('.grid-print-container');
    var link = document.createElement('link');
    link.id = 'minhaclass';
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = '~/css/better-scale,css';
    link.media = 'all';
    header.appendChild(link);
    L.control.graphicScale({
        fill: 'hollow',
        metric: true,
        imperial: false,
        position: 'bottomleft',
        labelPlacement: 'bottom'
    }).addTo(e.printMap);

});

If anybody needs this, this is a solution....