document.getElementById('export-png').addEventListener('click', function() {
map.once('rendercomplete', function(event) {
var canvas = event.context.canvas;
if (navigator.msSaveBlob) {
navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
} else {
canvas.toBlob(function(blob) {
saveAs(blob, 'map.png');
});
}
});
map.renderSync();
});
用demo的方法一点反应没有 除了install file-saver之外还有什么要注意的吗