Created
February 10, 2014 20:12
-
-
Save skorasaurus/8923293 to your computer and use it in GitHub Desktop.
UPDATED
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <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='https://api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.js'></script> | |
| <link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.css' rel='stylesheet' /> | |
| <style> | |
| body { margin:0; padding:0; } | |
| #map { position:absolute; top:0; bottom:0; width:100%; } | |
| </style> | |
| </head> | |
| <body> | |
| <script src='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-image/v0.0.3/leaflet-image.js'></script> | |
| <button id='snap' style='position: absolute; bottom: 10px; right: 10px;'>Snap image</button> | |
| <div id='images' style='float: right; width: 49%;'></div> | |
| <div id='map' style='width: 49%;'></div> | |
| <script type="text/javascript"> | |
| var map = L.mapbox.map('map', 'skorasaurus.jvs1kg0c', { | |
| center: [41.487556,-81.673393], | |
| zoom: 13 | |
| }); | |
| document.getElementById('snap').addEventListener('click', function() { | |
| leafletImage(map, doImage); | |
| }); | |
| function doImage(err, canvas) { | |
| var img = document.createElement('img'); | |
| img.width = 800; | |
| img.height = 400; | |
| img.src = canvas.toDataURL(); | |
| document.getElementById('images').innerHTML = ''; | |
| document.getElementById('images').appendChild(img); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment