Google Maps API V3 Printing Maps

前端 未结 5 1630
北海茫月
北海茫月 2020-12-09 14:13

I am looking for a method to efficiently print Google maps that have been implemented on a site using the google maps api v3.

I have seen some people using just the

5条回答
  •  鱼传尺愫
    2020-12-09 14:22

    In HTML, #Gmap is the div you display the google map, and Print Button will call function gmapPrint() once it has been clicked.

    
    
    Print Button

    In JavaScript, the gmapPrint() function read the map details and write it on a new window. Then print the new window.

    
    function gmapPrint() {
        var content = window.document.getElementById("Gmap"); // get you map details
        var newWindow = window.open(); // open a new window
        newWindow.document.write(content.innerHTML); // write the map into the new window
        newWindow.print(); // print the new window
    }
    

提交回复
热议问题