Javascript 使用图层/标记打印谷歌地图div
如何打印带有所有图层/标记的谷歌地图 使用Javascript 使用图层/标记打印谷歌地图div,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,如何打印带有所有图层/标记的谷歌地图 使用$('#map').html()并将内容放置在新窗口中不起作用。它仅显示地图基础层。例如,下面的代码不起作用 function PrintElem(elem) { Popup($(elem).html()); } function Popup(data) { var mywindow = window.open('', 'my div', 'height=400,width=600'); mywindow.document.w
$('#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;
}
函数PrintElem(elem)
{
弹出($(elem.html());
}
功能弹出窗口(数据)
{
var mywindow=window.open(“”,'my div','height=400,width=600');
mywindow.document.write('mydiv');
/*可选样式表*///mywindow.document.write(“”);
mywindow.document.write(“”);
mywindow.document.write(数据);
mywindow.document.write(“”);
mywindow.document.close();//对于IE>=10是必需的
mywindow.focus();//IE>=10所必需的
mywindow.print();
mywindow.close();
返回true;
}
将地图与横向/纵向匹配以进行打印也很好。我只是在打印优化的弹出窗口中重新创建了地图 打开弹出窗口:
mapData = {
data:someMapData(),
};
window.open('print.html', 'window1', 'height=750,width=1000');
从弹出窗口中,访问数据:
var data = window.opener.mapData;
在打印窗口中,我根据打印方向(横向/纵向)调整地图大小
它打印效果很好,就我而言,它比尝试从应用程序本身打印效果更好。您可以轻松获取管线数据、多段线、点等,并在地图上重新绘制 我只是在一个打印优化的弹出窗口中重新创建了地图 打开弹出窗口:
mapData = {
data:someMapData(),
};
window.open('print.html', 'window1', 'height=750,width=1000');
从弹出窗口中,访问数据:
var data = window.opener.mapData;
在打印窗口中,我根据打印方向(横向/纵向)调整地图大小
它打印效果很好,就我而言,它比尝试从应用程序本身打印效果更好。您可以轻松获取管线数据、多段线、点等,并在地图上重新绘制 您想打印包含创建地图脚本的
数据
?使用Google Static maps API()如何?找到解决方案了吗?您想打印包含创建地图脚本的数据
?使用Google Static maps API()如何?找到解决方案了吗?