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

Text of Leaflet Geoman Textlayer is not displayed #121

Closed Lauranna closed 1 year ago

Lauranna commented 1 year ago

Hello Igor-Vladyka,

thanks for your great plugin. I use the Leaflet Geoman-free plugin to give users the ability to insert graphics and text into the map themselves. All graphics are displayed wonderfully on the print page. Only the text in the text layer is not displayed. Here only an empty text field remains on the print page.

leaflet geoman textlayer not working for print

But all I see is that: print page with textarea

The text in the text box is missing. Do I have to include anything else here?

var browserPrint = L.control.browserPrint({ title: 'Bild exportieren', documentTitle: '...', printModes: [ L.BrowserPrint.Mode.Landscape("A4", {title: "Querformat"}), L.BrowserPrint.Mode.Portrait("A4", {title: "Hochformat"}) ], manualMode: false, closePopupsOnPrint: false, cancelWithEsc: false }).addTo(map);

I'm sorry, I'm quite a beginner, but I hope you understand my problem.

Regards, Lauranna

Falke-Design commented 1 year ago

Hi @Lauranna,

you need to add following:

L.BrowserPrint.Utils.registerLayer(L.Marker, 'L.Marker', function(layer, utils) {
    var options = utils.cloneOptions(layer.options);
    if(layer.pm && layer.pm.getShape() === 'Text') {
        options.text = layer.pm.getText();
        delete options.icon;
    }
    return L.marker(layer.getLatLng(), options);
});
Lauranna commented 1 year ago

Thank you very much. It works.