html2canvas does not work with Google Maps Pan

前端 未结 4 2025
终归单人心
终归单人心 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条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 19:48

    After a Google Maps update the solution of mfirdaus stop working, the new solution is this:

    var transform = $(".gm-style>div:first>div:first>div:last>div").css("transform")
    var comp = transform.split(",") //split up the transform matrix
    var mapleft = parseFloat(comp[4]) //get left value
    var maptop = parseFloat(comp[5])  //get top value
    $(".gm-style>div:first>div:first>div:last>div").css({ //get the map container. not sure if stable
      "transform": "none",
      "left": mapleft,
      "top": maptop,
    })
    

    is the same but u need to change de selector from

    .gm-style>div:first>div

    to

    .gm-style>div:first>div:first>div:last>div

    Hands up

提交回复
热议问题