title: Loading google maps in anonymous function
body: <p>I'm attempting to load google maps in an anonymous function but am getting a javascript error whenever I try to use one of the api's methods.  For example:</p>
  
  <p>Code</p>
  
  <pre><code>var mapOptions = {
        zoom: 8,
        center: new google.maps.LatLng(-34.397, 150.644),
        mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>TypeError: google.maps.LatLng is not a constructor
  </code></pre>
  
  <p>I've created 2 examples:</p>
  
  <p>1) This loads google map js via script tag in the body of the page.  This method DOES work and there is no js error.  <a href="http://jsfiddle.net/malonso/hgPQk/1/" rel="noreferrer">http://jsfiddle.net/malonso/hgPQk/1/</a></p>
  
  <p>2) This loads google map js w/in the anonymous function.  This method does NOT work and contains the js error mentioned above. <a href="http://jsfiddle.net/malonso/fZqqW/2/" rel="noreferrer">http://jsfiddle.net/malonso/fZqqW/2/</a></p>
  
  <p>I am sure I'm missing something glaringly obvious but I simply cannot figure out what.  Thanks in advance.</p>
  
  <p>Update: I should point out that it is a requirement that google maps be loaded from w/in the anonymous function.</p>