Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving Leaflet.js maps as a static image

Tags:

image

leaflet

I'm trying to find a good method for allowing end users to save Leaflet.js maps as a static image (e.g. PNG, JPG, etc.). Mapbox.js (built on top of Leaflet.js) provides a nice method, but I assume this requires having your maps hosted on Mapbox so that they have a Map ID through their API. Does anyone know how I can do this with a Leaflet.js map that cannot be called through an API? Such as my example here?

Thank you all! Eli

like image 920
Eli Kern Avatar asked Aug 17 '14 02:08

Eli Kern


People also ask

How do you save a map on Leaflet?

In the viewer tab, above the map, you will find an export button to save leaflets as an image.

Does Leaflet use OpenStreetMap?

The Leaflet JavaScript. Our initial JavaScript is pretty straightforward. All we are doing here is creating the map and adding a tile layer. The tile images are coming from the OpenStreetMap servers which are good for testing.

Does Leaflet use Mapbox?

Leaflet is an open-source JavaScript library used for web mapping. The Leaflet library forms the basis of Mapbox.

Can I use Google Maps on my Leaflet?

Using the leaflet, we can render the map into an HTML element and we can set the marker on the map. Leaflet works efficiently across all major desktop and mobile platforms.


1 Answers

This thread is a bit dated, at the time of this answer, but there are a few leaflet plugins that appear to tackle this now.

Leaflet Print Plugins

like image 172
Jason Koopmans Avatar answered Oct 17 '22 07:10

Jason Koopmans