打印带有方向的谷歌地图 [英] Print google map with directions on it
问题描述
我在我的webapp上使用了Google地图 - 使用JavaScript API V3。
我给予我的用户使用谷歌地图方向管理一些路线的能力。
现在,我的问题是我想给他们打印它的能力(只是地图,而不是整个网站)。
我试过如下:
var OpenWindow = window.open(_ blank,,'');
var contents = document.getElementById(mapMainCanvas);
OpenWindow.document.write(contents.innerHTML);
这确实会在地图上打开一个新选项卡,但没有方向。
另外,我在API中找不到任何打印选项。
是否有人解决了这个问题?
谢谢。
<试试这个:
var content = document.getElementByID('mapMainCanvas'); //必须是第一个。
var win = window.open();
win.document.write(content);
win.print();
win.close();
我希望它能起作用!
(请让我知道如果它没有。)
I've got google map on my webapp - working with the JavaScript API V3. I give my users the ability to manage some routes, using the google map directions. Now, my problem is that I want to give them the ability to print it (just the map, not the entire website).
I've tried the following:
var OpenWindow = window.open("_blank", "", '');
var contents = document.getElementById("mapMainCanvas");
OpenWindow.document.write(contents.innerHTML);
This indeed open a new tab with the map, but without the directions. Also, I couldn't find any "print" option in the API. Does anybody solved this problem?
Thanks.
Try this:
var content = document.getElementByID('mapMainCanvas'); //has to be first.
var win = window.open();
win.document.write(content);
win.print();
win.close();
I hope it will work!
(Please let me know if it does or not.)
这篇关于打印带有方向的谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!