html2canvas does not work with Google Maps Pan

前端 未结 4 2028
终归单人心
终归单人心 2020-11-27 18:55

I\'m using html2canvas to save my online map as an image (See the Save as Image link). I\'ve tried it in Firefox, Chrome and Opera.

It tends to work more often if

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 19:49

    I have the same problem, but I used Leaflet Map instead of Google Map.

    The code is below

    var transform=$(".leaflet-map-pane").css("transform");
    if (transform) {
        var c = transform.split(",");
        var d = parseFloat(c[4]);
        var h = parseFloat(c[5]);
        $(".leaflet-map-pane").css({
            "transform": "none",
            "left": d,
            "top": h
        })
    }           
    
    
    html2canvas(document.body).then(function(canvas){
        $(".leaflet-map-pane").css({
            left: 0,
            top: 0,
            "transform": transform
        })
       }
    // Here is used html2canvas 1.0.0-alpha.9
    

提交回复
热议问题