Skip to content

gijs/leaflet-image

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leaflet-image

Export images out of Leaflet maps without a server component, by using Canvas and CORS.

example

var map = L.mapbox.map('map', 'tmcw.map-u4ca5hnt').setView([38.9, -77.03], 14);
leafletImage(map, function(canvas) {
    // now you have canvas
});

// example thing to do with that canvas
function doImage(err, canvas) {
    var img = document.createElement('img');
    var dimensions = map.getSize();
    img.width = dimensions.x;
    img.height = dimensions.y;
    img.src = canvas.toDataURL();
    document.getElementById('images').innerHTML = '';
    document.getElementById('images').appendChild(img);
}

api

leafletImage(map, callback)

map is a L.map or L.mapbox.map, callback takes (err, canvas).

Releases

No releases published

Packages

No packages published