【问题标题】:Convert Google Map DIV into an image将 Google Map DIV 转换为图像
【发布时间】:2014-02-13 10:57:28
【问题描述】:

这是对我的问题的简化,但我想澄清一下。

我在 div 中安装了一个 Google 地图对象。地图完美返回。

上面有 WMS 覆盖(例如,1990 年出生的人的数据地图)。地图上的 WMS 图层正在完美返回。

我的问题是如何将包含 Google Map 和 WMS 的 DIV 画布转换为图像,即 PNG/GIF?

我查看了静态地图 API,但它并不好,因为我正在调用 WMS 图层。需要使用 Google APIv3

【问题讨论】:

  • 为什么要把div转成图片格式?也许还有另一种方法可以解决您的问题。
  • 我也一直在研究这个问题,在这里发布了更详细的帖子stackoverflow.com/questions/38487549/…

标签: javascript web map maps


【解决方案1】:

You can use this Example and convert div to image

或使用此代码

$(function() { 
    $("#btnSave").click(function() { 
        html2canvas($("#widget"), {
            onrendered: function(canvas) {
                theCanvas = canvas;
                document.body.appendChild(canvas);

                // Convert and download as image 
                Canvas2Image.saveAsPNG(canvas); 
                $("#img-out").append(canvas);
                // Clean up 
                //document.body.removeChild(canvas);
            }
        });
    });
}); 

【讨论】:

    猜你喜欢
    • 2012-02-17
    • 2010-11-04
    • 1970-01-01
    • 2012-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-24
    • 2019-12-08
    相关资源
    最近更新 更多