leaflet-easyPrint
leaflet-easyPrint copied to clipboard
Cannot read property 'width' of undefinded
Hello, I want to create a Button in my bootstrap dropdown menu to print a leaflet map. So I have the following Code:
var printer = L.easyPrint({
sizeModes: ['A4Landscape'],
tileLayer: cartoLight,
hideControlContainer: true,
}) .addTo(map);
And I create a function:
$("#printer-btn").click(function() { printer.printMap('A4Landscape'); $(".navbar-collapse.in").collapse("hide"); return false; });
But now, when I click my printbutton in the dropdown menu I get the following error in my chrome console:
oops, something went wrong! TypeError: Cannot read property 'width' of undefined at e._resizeAndPrintMap (bundle.js:1) at bundle.js:1
What can I do? I installed the latest version from the repository.
It might me years now that I get this message. Could not find a solution.
Seems that the problem is in the code of bundle.js. I could not find any way to handle “width” in my own code.
Von: firechhe [email protected] Gesendet: Sonntag, 6. Oktober 2019 20:43 An: rowanwins/leaflet-easyPrint [email protected] Cc: Subscribed [email protected] Betreff: [rowanwins/leaflet-easyPrint] Cannot read property 'width' of undefinded (#105)
Hello, I want to create a Button in my bootstrap dropdown menu to print a leaflet map. So I have the following Code:
var printer = L.easyPrint({ sizeModes: ['A4Landscape'], tileLayer: cartoLight, hideControlContainer: true, }) .addTo(map);
And I create a function:
$("#printer-btn").click(function() { printer.printMap('A4Landscape'); $(".navbar-collapse.in").collapse("hide"); return false; });
But now, when I click my printbutton in the dropdown menu I get the following error in my chrome console:
oops, something went wrong! TypeError: Cannot read property 'width' of undefined at e._resizeAndPrintMap (bundle.js:1) at bundle.js:1
What can I do? I installed the latest version from the repository.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rowanwins/leaflet-easyPrint/issues/105?email_source=notifications&email_token=ABPGDZNP6QGQ233EIHHQDBLQNIWURA5CNFSM4I55GPIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HP5LATQ , or mute the thread https://github.com/notifications/unsubscribe-auth/ABPGDZPUFTRN3PZD2SQJ53LQNIWURANCNFSM4I55GPIA . https://github.com/notifications/beacon/ABPGDZIPUZ4YMDAMJ76BN33QNIWURA5CNFSM4I55GPIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HP5LATQ.gif
Oh ok. That is not good. Maybe the developer of easyprint can help?
I solved it by adding word page to the first argument. printPlugin.printMap('A4Landscape page', 'MyFileName');
These no longer seem to be working. When using 'A4Landscape page' or 'A4Portrait page' it seems to be giving the 'oops, something went wrong! TypeError: Cannot read properties of undefined (reading 'width')' error, still.
Oops! Nevermind, the relevant option needs to be provided to sizeModes as well! (sizeModes=['A4Portrait'] to call printMap('A4Portrait page'))
A4Portrait page works A4Landscape page NOT