5

How can I generate a image of a div, the div contain a map of leaflet (base layers, overlays)?

Screenshot_Leaflet_Div

Lucky
  • 16,787
  • 19
  • 117
  • 151
Kenyo Joel
  • 191
  • 3
  • 6
  • You can provide a print button to print map area. You can also make use of a leaflet print plugin. https://github.com/rowanwins/leaflet-easyPrint – SSA Oct 07 '15 at 08:57

2 Answers2

1

Mapbox's leaflet-image plugin will allow you to kick out an image file of your map container clientside.Enabling canvas mode is required, as seen in their instructions. A more involved server-side approach would include the use of Mapfish/Geoserver and a leaflet plugin, which has a lot more flexibility, but also a lot more configuration.

snkashis
  • 2,951
  • 1
  • 18
  • 35
0

What I did on a project was run a nodejs rest api that would launch a chromium instance using puppeteer take a screenshot of a map using long lat and then return the image as a base64. It might be more efficient to generate a map image serverside using leaflet or something else rather than taking a screenshot of a browser.

https://github.com/lastlink/re-store/tree/master/webscraper

lastlink
  • 1,505
  • 2
  • 19
  • 29