Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map Moves After Print Action #131

Open
outputtxt opened this issue Feb 12, 2024 · 3 comments
Open

Map Moves After Print Action #131

outputtxt opened this issue Feb 12, 2024 · 3 comments

Comments

@outputtxt
Copy link

Hi, I am using this plugin with "react-leaflet": "^4.2.1", and I am experiencing 2 unwanted behavior in my project.

  1. Custom Selection acquires wrong coordinates. The printed area is always bottom right corner of selected area.
  2. After print action, printed or cancelled, map always moves to bottom right corner.

by bottom right corner, I mean, map div moves down by current height, and moves right by current width.
I am using Edge, Version 120.0.2210.133 (Official build) (64-bit)

My code is :

L.control.browserPrint({
      position: "topleft",
      title: "Print",
      printModes: [
        L.BrowserPrint.Mode.Landscape("A4", {
          margin: 2,
          title: "Horizontal",
          // invalidateBounds: false,
          header: {
            enabled: true,
            text: " ",
            size: "0mm",
          },
          footer: {
            enabled: true,
            text: " ",
            size: "0mm",
          },
        }),

        L.BrowserPrint.Mode.Custom("B1", {
          orientation: "Landscape",
          title: "Select Area",
          margin: 2,
        }),
      ],
      documentTitle: "MyProject",
    }).addTo(map);

Any help is appreciated, best regards.

@Jackidu54
Copy link

Jackidu54 commented Feb 16, 2024

Same problem here using Chrome,

Logs say :

leaflet.browser.print.js:92 Uncaught TypeError: Cannot set properties of undefined (setting 'start')
at NewClass._startAutoPolygon (leaflet.browser.print.js:92:29)
at NewClass.fire (leaflet.js?v=7dea7d77:387:20)
at NewClass._fireDOMEvent (leaflet.js?v=7dea7d77:2959:24)
at NewClass._handleDOMEvent (leaflet.js?v=7dea7d77:2923:16)
at HTMLDivElement.handler (leaflet.js?v=7dea7d77:1733:21)

Downgrading the plugin to 1.0 does not change anything

@outputtxt
Copy link
Author

if I comment the line below inside leaflet.browser.print.js, the map movement stops:

this._map.invalidateSize({reset: true, animate: false, pan: false});

And I tried some possible alternatives on custom select, after changing the page size to A3 and adding header true but 0mm, the wrong area selection error is also gone.

Bu meanwhile I found out that, paper header/footer props are not working well on different browsers.
In my case, even with false, it still continues to draw header/footer on edge.

@Falke-Design
Copy link
Contributor

I can't reproduce this error. @outputtxt can you please create a demo: https://plnkr.co/edit/CX484lkQSfC0mr4m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants