Embedding Google Maps in Web Pages Served as application/xhtml+xml

I ran into trouble while trying to embed a Google Map into a page with Content-Type of application/xhtml+xml. I tried a few different ways of loading the script and initializing the GMap2 object, but they all ended up with Mozilla giving a somewhat cryptic error message (quotemarks exactly as below):

Object cannot be created in this context" code: "9

Turns out that Google's code uses the document.write() method and that that does not work with documents served as application/xhtml+xml. Which means that the pages must be served as text/html. I hope I could find a better solution but for now, that'll have to do.