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

Export Map to PNG #49

Closed euangordon closed 5 years ago

euangordon commented 5 years ago

Is there any way to export to png instead of printing? Would be a nice feature to add to a Print / Export menu.

Igor-Vladyka commented 5 years ago

Please use other plugin to export it as PNG, this plugin can only call browser print action for now.

euangordon commented 5 years ago

Please use other plugin to export it as PNG, this plugin can only call browser print action for now.

Thanks @Igor-Vladyka, I have used easyPrint.js to get a PNG of the map in the browser for the moment.

One thing I quite like about Browser Print is that I can print a different base map from the one being viewed by the user. At the moment we normally display a simple basemap, but on print we are printing a high quality Sea Map from Transas.

My ideal solution is going to be for the user to select that he wants to print a "Route Report" from the browser, this will send his route (waypoints on the map) to the API controller. The controller will render the map in a headless brower, plot the waypoints on the map and zoom the map so that all waypoints are in view. Create a png of this image and then sent it to jsReports to be included in a PDF report which will be viewed / downloaded by the user.

Igor-Vladyka commented 5 years ago

Current plugin prepares map to print and uses in-browser action for actual printing. You can override actual browser behavior. Here is more details: download-map-as-image And full example with added custom action to export image in AUTO mode.

Regards, Igor