Google Maps API – No XHTML Support
I’ve been playing around with the Google Maps API recently as I attempt to write an article on its usage. Right off the bat, I found a problem.
All of the pages on my site are served up as proper XHTML, including the XML prolog and serving the pages up as application/xhtml+xml in Firefox. Apparently, this causes the Google Maps API fits because it wants to use document.write(), which doesn’t exist in the XHTML DOM.
A quick search through the Google Maps API Group reveals no answer other than, “remove the XML declaration and don’t serve up your page as application/xhtml+xml.” What? You’ve got to be kidding me. This seems to be a major oversight of the Google Maps API team, to use a feature that is deprecated. All of the examples provided use the strict XHTML but we’re not actually supposed to have valid strict XHTML? I hope someone is looking into fixing this.
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.
Both comments and pings are currently closed.




2 Comments
This is a hacky workaround, but it almost works:
http://persistent.info/tmp/maps-api-xhtml.html
What I did was to override the write() method on the document to just capture what its given. Then I inserted that markup myself into the page (I tried to generalize this by using DOMParser, parsing the strings, and appending them to the document, but it didn’t work).
The map now has issues with tile displaying, but that may be Firefox’s fault.
Mihai Parparita on March 29th, 2006 at 11:27 am
After hours to make the embed quicktime video work in google map maker info window I find this email that finally explains what I see. It works in Firefox but not in IE. Shame…
Lefteris Koumis on July 20th, 2006 at 4:01 pm
Comments are automatically closed after 14 days.