Print google map together with marker!

7,825 views
Skip to first unread message

Daejeon

unread,
Jul 14, 2011, 4:18:37 AM7/14/11
to google-map...@googlegroups.com
(QUOTE from some where)

There are several other questions addressing this issue: How to print Google Map markers

The short, the Google Maps Javascript API doesn't print overlays (markers, lines) correctly or at all. You can use the Google Maps Static API, but you will be limited to the amount of overlays you draw on the map. This is, however, the best way to get a reliable print. http://code.google.com/apis/maps/documentation/staticmaps/#Markers

The long, the markers have the class 'gmnoprint', which disables them from showing up on the printed rendering. You can iterate through the markers and remove this class, which should allow them to be printed on the page. As far as I know, this will not work for the direction lines.

I suppose: Method 2 need to have some knowledge on DOM so that can remove the class gmnoprint for every marker, since I am a newbie so I would go for method one. 
However, my map is created by api v3, how am I going to retrieve the URL to generate static image? 
Thanks


Chris Broadfoot

unread,
Jul 14, 2011, 9:13:31 AM7/14/11
to google-map...@googlegroups.com
On Thu, Jul 14, 2011 at 6:18 PM, Daejeon <siaw.m...@gmail.com> wrote:
The short, the Google Maps Javascript API doesn't print overlays (markers, lines) correctly or at all.

It seems to work for me (in Chrome/Mac) at least. What browser are you having troubles with?

--


Daejeon

unread,
Jul 14, 2011, 10:35:37 AM7/14/11
to google-map...@googlegroups.com
I am using Chrome as well.

<div id="map" ... weight = height =></div>  // I am sorry not providing full code, just to show that, I have this. because I don't have code with me now.

At first place an image button, 
<img src="images/print.png" title="print" onclick="window.open('print.html')" />

and after that, I create another html document. 
<script language="javascript">
var contents = window.opener.document.getElementById("map");
document.write(contents.innerHTML);
window.print();
</script>
However, this method could only show the map without any marker on it. Are you using the same method? Thank you.

en4ce

unread,
Jul 14, 2011, 12:46:05 PM7/14/11
to Google Maps JavaScript API v3
check my print function here: http://www.youspots.com/?mapid=3255

its nothing special but it plots markers and poly´s etc

Chris Broadfoot

unread,
Jul 14, 2011, 10:25:11 PM7/14/11
to google-map...@googlegroups.com
On Fri, Jul 15, 2011 at 12:35 AM, Daejeon <siaw.m...@gmail.com> wrote:
<script language="javascript">
var contents = window.opener.document.getElementById("map");
document.write(contents.innerHTML);
window.print();
</script>
I can't imagine this working. You can't copy a map by copying over the innerHTML. What's wrong with regular window.print()?

--


Daejeon

unread,
Jul 21, 2011, 10:19:17 PM7/21/11
to google-map...@googlegroups.com
window.print() works well.

However, I would have to resize the map (for nice printing), add the title/date on the map. 
Whenever users print the map, I would able to save a copy of the map as well... something like this.
Hm... I am still reading the api v3 documentation, but I couldn't find any example of it. 

Appreciate if you could give me some suggestion. Thanks a lot!

Rossko

unread,
Jul 22, 2011, 5:33:04 AM7/22/11
to Google Maps JavaScript API v3
> window.print() works well.
...
> Appreciate if you could give me some suggestion. Thanks a lot!

Okay, you're happy with print. What do you want a suggestion for,
copying the map to save? Not allowed.
Reply all
Reply to author
Forward
0 new messages