title: Google maps api fails to load?
body: <p>I am trying to include a google map in my webpage, using the google maps api.</p>
  
  <p>In my html I have in my header:</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"&gt;    &lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>Note that I am using 'https' as otherwise I get security errors...</p>
  
  <p>and my body tag is:</p>
  
  <pre><code>&lt;body window.onload="initialize()"&gt;
  </code></pre>
  
  <p>and I have a div containing the map:</p>
  
  <pre><code>&lt;div id="map_canvas"&gt;&lt;/div&gt;   
  </code></pre>
  
  <p>and in the external javascript file I have a function initialize() which should load the map into the map_canvas div. I tried writing the page on my own computer, and visiting it with my browser, with no web server running, and it was fine - the map showed up as it should have.</p>
  
  <p>I have tried 'inspect element' and the error I get is</p>
  
  <pre><code>Uncaught TypeError: Object #&lt;Document&gt; has no method 'write' js?sensor=false:8
  </code></pre>
  
  <p>which corresponds to this code snippet:</p>
  
  <pre><code>function getScript(src) {
  document.write('&lt;' + 'script src="' + src + '"' +
                 ' type="text/javascript"&gt;&lt;' + '/script&gt;');
  }
  </code></pre>
  
  <p>Any ideas where I'm going wrong? The only thing I can think is that the map cannot be loaded before the rest of th page, but if so I'm not sure how to fix this....any help is much appreciated! I've been googling for hours with no luck..</p>
  
  <p>I think the problem may be to do with the fact that I'm writing in XHTML but the api uses 'document.write', which is illegal - is there a way to get around this?</p>