Closed Lauranna closed 7 months ago
Hello.
When doing custom or auto mode tiles could not be loaded during pre-init actions. You can try instead get bounding box in L.BrowserPrint.Event.Print event. Also you can check parameters passed from the even (e.printLayer). Or just get map center and calculate your own bonds based on it.
Hello Igor, thank you very much for your reply. I've found a solution that works well for me. I followed your proposal to calculate my own boundingbox from map center.
` Here is the code:
var watermarkOverlay;
map.on(L.BrowserPrint.Event.PrintInit, function() {
var overlayCenter = L.latLng(map.getCenter());
var mapZoom = map.getZoom();
var pixWidth = 511;
var pixOffsetX = pixWidth / 2;
var pixOffsetY = pixOffsetX * 15 / 27;
var centerPoint = map.project(overlayCenter, mapZoom);
var latLng1 = map.unproject(L.point([centerPoint.x - pixOffsetX, centerPoint.y + pixOffsetY]), mapZoom);
var latLng2 = map.unproject(L.point([centerPoint.x + pixOffsetX, centerPoint.y - pixOffsetY]), mapZoom);
var overlayBounds = L.latLngBounds(latLng1, latLng2);
watermarkOverlay = L.imageOverlay("images/WasserzeichenNeu.png", overlayBounds, {
opacity: 0.5
});
watermarkOverlay.addTo(map);
});
map.on(L.BrowserPrint.Event.PrintEnd, function() {
watermarkOverlay.removeFrom(map);
map.closePopup();
});
`
Greetings, Anna
Hello, first of all, thanks for the great plugin and your work on it. I try to place a svg as watermark on the print page. On "Landscape" and "Portrait" Mode it works tolerably. On "Custom" mode the bounds don't work.
Here is my Code:
`
`
I tried to place it into the bounds of the selected area, but somehow it goes where it wants.
Here an example:![print watermark example](https://github.com/Igor-Vladyka/leaflet.browser.print/assets/7869457/a9db5882-06d1-4102-833c-51ad5d41682f)
the image here is in the left upper corner, bat I want it centered and the hole image on the printed map. It should be much smaller. The bounds of the PrintInit Event doesn't work here.
Has anyone some ideas what I didn't notice or have other solutions for doing that?
Thanks in advance.