2010-09-07 57 views

回答

0

有解決這個問題的其他幾個問題: How to print Google Map markers

短,谷歌地圖API的Javascript不打印覆蓋(標記,線)正確或完全。您可以使用Google Maps靜態API,但限制在地圖上繪製的疊加層數量。但是,這是獲得可靠打印的最佳方式。

長,標記有類'gmnoprint',它禁止他們顯示在打印的渲染。您可以遍歷標記並刪除此類,這應該允許將它們打印在頁面上。據我所知,這不適用於方向線。

0

很多天試圖打印圖標和路線,所以最後我做到了!!!!!!!! 我發現一個js script that convert html to canvas,我認爲這將是解決方案,但不幸的是,它根本就沒有。

如果發現,當我使用它,並說瀏覽器打印頁面終於顯示它!但畫布再次不顯示圖標¿...?

所以我只是在加載時執行腳本並將結果畫布追加到地圖背後的div上(如果你把顯示器:沒有不工作!)。我的英語:) 這裏有點不好意思代碼:

<div id="imprimir"> 
    <h1><?php echo $direccion;?></h1> 
    <div id="distancia"></div> 
    <div id="map-canvas" style="margin: 0;padding: 0; height: 550px;z-index:10"></div>       
    <div id="captura" style="position:absolute;top:100px;left:50px;"></div> 
</div> 
//------------ ... 
Google Map code here 
//------------ ... 
<script> 
    html2canvas($("#imprimir"), { 
     onrendered: function(canvas) { 
      $("#captura").html(canvas);           
     } 
    });    
</script> 

很好,我希望這可以幫助您!

0
$("#btnPrint").click(function() { 
     var contents = $("#map_canvas").html(); 
     var frame1 = $('<iframe />'); 
     frame1[0].name = "frame1"; 
     frame1.css({ "position": "absolute", "top": "-1000000px" }); 
     $("body").append(frame1); 
     var frameDoc = frame1[0].contentWindow ? frame1[0].contentWindow : frame1[0].contentDocument.document ? frame1[0].contentDocument.document : frame1[0].contentDocument; 
     frameDoc.document.open(); 
     //Create a new HTML document. 
     frameDoc.document.write('<html><head><title>DIV Contents</title>'); 
     frameDoc.document.write('</head><body>'); 
     //Append the external CSS file. 
     frameDoc.document.write('<link href="style.css" rel="stylesheet" type="text/css" />'); 
     //Append the DIV contents. 
     frameDoc.document.write(contents); 
     frameDoc.document.write('</body></html>'); 
     frameDoc.document.close(); 
     setTimeout(function() { 
      window.frames["frame1"].focus(); 
      window.frames["frame1"].print(); 
      frame1.remove(); 
     }, 500); 
    });