zoukankan      html  css  js  c++  java
  • openlayers 保存当前地图View为图片

    /**
    * 保存地图为图片工具栏
    */
    function addMapToolSavePicture() {

    var saveElement = document.createElement('a');
    saveElement.className = "mapbtn glyphicon glyphicon-picture";
    saveElement.setAttribute("data-toggle", "tooltip");
    saveElement.setAttribute("data-placement", "left");
    saveElement.setAttribute("title", "SavePicture");
    saveElement.onclick = function() {

         // 此方法只能保存背景地图及图层数据,但是不能保存control,使用 html2canvas 可以保存地图控件信息,比如图例信息等。
    // olMap.once('postcompose',
    // 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');
    // // });
    // }
    // });
    // olMap.renderSync();


    html2canvas(document.getElementById(mapId)).then(
    function (canvas) {
    canvas.toBlob(function (blob) {

    saveAs(blob,'map.png');

    });
    });
    };

    document.getElementById(soToolBarId).appendChild(saveElement);
    }
  • 相关阅读:
    多按键设计的标准思路
    与,非,或门总结
    i2c中应答信号信号总结
    i2c中start和restart的区别
    poj 1631 Bridging signals
    poj 2533 Longest Ordered Subsequence
    poj 1887 Testing the CATCHER
    poj 1088 滑雪
    poj 1014 Dividing
    babel转码时generator的regeneratorRuntime
  • 原文地址:https://www.cnblogs.com/googlegis/p/9979176.html
Copyright © 2011-2022 走看看