Skip to content

Instantly share code, notes, and snippets.

Forked from wboykinm/index.html
Last active Aug 29, 2015
What would you like to do?
<!DOCTYPE html>
<meta charset=utf-8 />
<title>Leaflet Image</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<script src=''></script>
<link href='' rel='stylesheet' />
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
#snap {position: absolute; bottom: 10px; left: 10px; z-index: 99;}
<script src='//'></script>
<button id='snap'>Map Snapshot</button>
<div id='images' style='float: right;'></div>
<div id='map' style='width: 70%;'></div>
<script type="text/javascript">
var map ='map', 'faraday2.hi7p6kfl', {
center: [44.5, -73.2],
zoom: 12
document.getElementById('snap').addEventListener('click', function() {
leafletImage(map, doImage);
//var box2d = map.getBounds();
function doImage(err, canvas) {
var img = document.createElement('img');
var dimensions = map.getSize();
imgRatio = dimensions.x / dimensions.y;
img.width = 300;
img.height = 300 / imgRatio;
img.src = canvas.toDataURL();
document.getElementById('images').innerHTML = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment