[Solved] Want to use print functionality for Google Map in ASP.Net

Last Reply 10 months ago By Rucha

Posted 10 months ago

Hello, I want to create print functionality of google map in my asp.net web application.

I use the following code for that,

<script language="javascript">        
         var contents = window.opener.document.getElementById("dvMap");            
         document.write(contents.innerHTML);
         window.print();
  </script>  

    <input type="button" value="Print" onclick="javascript:this.style.display='none';window.print();this.style.display='';" />

But while i am clicking on print button it will open print page but not show the map which i want to print,it show blank page.please refere following image.

https://ibb.co/bw1EvH

What is the solution?please suggest

Thanks.

You are viewing reply posted by: Rucha 10 months ago.
Posted 10 months ago

Hello 

Thanks for your support.

But it is not working i dont understand what to do.

I have tried another javascript function like below to print map.

 

    function PrintDoc() {

        var toPrint = document.getElementById('dvMap');

        var popupWin = window.open('', '_blank', 'width=700,height=400,location=no,left=200px');

        popupWin.document.open();

        popupWin.document.write('<html><title>::Preview::</title><link rel="stylesheet" type="text/css" href="print.css" /></head><body onload="window.print()">')

        popupWin.document.write(toPrint.innerHTML);

        popupWin.document.write('</html>');

        popupWin.document.close();

    }
    function PrintPreview() {

        var toPrint = document.getElementById('dvMap');
        var popupWin = window.open('', '_blank', 'width=700,height=400,location=no,left=200px');

        popupWin.document.open();

        popupWin.document.write('<html><title>::Print Preview::</title><link rel="stylesheet" type="text/css" href="Print.css" media="screen"/></head><body">')

        popupWin.document.write(toPrint.innerHTML);
       
        popupWin.document.write('</html>');
        //directionsService.route(request, function(response, status) {
        //    if (status == google.maps.DirectionsStatus.OK) {
        //        directionsDisplay.setDirections(response);
        //    }
        //});
        popupWin.document.close();

    }

So i got an answer for that particuler issue.

Now i have to mark any answer??Please let me know

Thanks