Export canvas map as jpeg image

This commit is contained in:
Frederic Junod
2013-01-21 15:24:45 +01:00
parent 2f2ea373ca
commit 8cbe0fbbbb
2 changed files with 5 additions and 1 deletions

View File

@@ -21,7 +21,7 @@
<tr>
<th>DOM</th>
<th>WebGL</th>
<th>Canvas</th>
<th>Canvas <a id="canvas-export" href="#" download="map.png">export map as png</a></th>
</tr>
<tr>
<td><div id="domMap" class="map"></div></td>

View File

@@ -48,3 +48,7 @@ var canvasMap = new ol.Map({
});
canvasMap.bindTo('layers', webglMap);
canvasMap.bindTo('view', webglMap);
goog.events.listen(goog.dom.getElement('canvas-export'), 'click', function(e) {
e.target.href = canvasMap.getRenderer().getCanvas().toDataURL();
});