【发布时间】:2016-01-02 01:07:18
【问题描述】:
如何打印带有所有图层/标记的 Google 地图?
使用$('#map').html() 并将内容放在新窗口中不起作用。它只显示地图基础层。例如,下面的代码不起作用。
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title>my div</title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
return true;
}
将地图适合横向/纵向进行打印也会很好。
【问题讨论】:
-
您要打印具有创建地图脚本的
data? -
使用谷歌静态地图API(developers.google.com/maps/documentation/static-maps)怎么样?
-
你找到解决办法了吗?
标签: javascript google-maps google-maps-api-3