Flexberry / Leaflet.Export

Leaflet.Export support additional methods for export, download and print maps
https://flexberry.github.io/Leaflet.Export/
MIT License
42 stars 11 forks source link

Background tiles overlay drawn polygon areas on right and bottom of image #4

Open DanlgArmstrong opened 6 years ago

DanlgArmstrong commented 6 years ago

have a website project using leaflet.js to create maps of survey data. The map renders nicely in the browser, however when I capture the image using leaflet-export.js (which calls html2canvas), the background tiles of the map cover parts of the county boundary polygons along the right and bottom edges of the image. My guess is that it is an html2canvas bug but perhaps someone can help.

In the browser my map shows like this: Good Map After capturing the image (used to create a powerpoint slide) I get this: Bad Image

The javascript capture function is :

`function getMapImage(reportId, callback) {

function afterRender(canvas) {

if (showLegend == true) {
    html2canvas(document.querySelector("#legend")).then(function (c) {
             returnMapImage(reportId, canvas.toDataURL(), c.toDataURL(), callback);
    });
}
else {
    returnMapImage(reportId, canvas.toDataURL(), null, callback);
}

} var downloadOptions = { container: leafMap.container,
exclude: ['.leaflet-control-zoom', '.leaflet-control-attribution'], format: 'image/png', afterRender: afterRender, afterExport: afterExport }; var promise = leafMap.export(downloadOptions); var data = promise.then(function (result) { return result; }); };`

ragim444 commented 5 years ago

have same issue... do you find resolve?

DanlgArmstrong commented 5 years ago

Nope - living with it till now. If someone finds a fix please let me know! Thanks

On Wed, Jan 9, 2019 at 10:00 AM Ragim notifications@github.com wrote:

have same issue... do you find resolve?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Flexberry/Leaflet.Export/issues/4#issuecomment-452726479, or mute the thread https://github.com/notifications/unsubscribe-auth/AGmoDRyC5C7bbezAb7d3iBiuIJdCSOKoks5vBgP5gaJpZM4R2Ae- .

ragim444 commented 5 years ago

Nope - living with it till now. If someone finds a fix please let me know! Thanks On Wed, Jan 9, 2019 at 10:00 AM Ragim @.***> wrote: have same issue... do you find resolve? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#4 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AGmoDRyC5C7bbezAb7d3iBiuIJdCSOKoks5vBgP5gaJpZM4R2Ae- .

Hello! I found a simple solution to our problem!

  1. Set renderer padding value (https://leafletjs.com/reference-1.4.0.html#renderer-padding) = 0
  2. Set the "windowWidth" value (http://html2canvas.hertzen.com/configuration) = document.documentElement.clientWidth.

I hope this helps you! Good luck.

DanlgArmstrong commented 5 years ago

Thanks Ragim!!!! Setting the renderer padding to zero did the trick for me. I did a global replace of all instances of L.canvas() to L.canvas({padding:0}) in my leaflet script file and now my captures render perfectly.

Very much appreciated!

ragim444 commented 5 years ago

Thanks Ragim!!!! Setting the renderer padding to zero did the trick for me. I did a global replace of all instances of L.canvas() to L.canvas({padding:0}) in my leaflet script file and now my captures render perfectly.

Very much appreciated!

I am very glad that I could help! Thank you for your feedback.

Ashirbayev commented 1 year ago

Nope - living with it till now. If someone finds a fix please let me know! Thanks On Wed, Jan 9, 2019 at 10:00 AM Ragim @.***> wrote: have same issue... do you find resolve? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#4 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AGmoDRyC5C7bbezAb7d3iBiuIJdCSOKoks5vBgP5gaJpZM4R2Ae- .

Hello! I found a simple solution to our problem!

  1. Set renderer padding value (https://leafletjs.com/reference-1.4.0.html#renderer-padding) = 0
  2. Set the "windowWidth" value (http://html2canvas.hertzen.com/configuration) = document.documentElement.clientWidth.

I hope this helps you! Good luck.

Nope - living with it till now. If someone finds a fix please let me know! Thanks On Wed, Jan 9, 2019 at 10:00 AM Ragim @.***> wrote: have same issue... do you find resolve? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#4 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AGmoDRyC5C7bbezAb7d3iBiuIJdCSOKoks5vBgP5gaJpZM4R2Ae- .

Hello! I found a simple solution to our problem!

  1. Set renderer padding value (https://leafletjs.com/reference-1.4.0.html#renderer-padding) = 0
  2. Set the "windowWidth" value (http://html2canvas.hertzen.com/configuration) = document.documentElement.clientWidth.

I hope this helps you! Good luck.

Can you tell me exactly how you decided? Сontact me if you can https://vk.com/ashirbayev t.me/Ashirbayev_e