title: Uncaught ReferenceError: google is not defined
body: <p>I want to use geolocation and direction function, but there is <code>google is not defined</code> error. the code is as below:</p>
  
  <pre><code>function loadScript() {
              var script = document.createElement('script');
              script.type = 'text/javascript';
              script.src = "https://maps.googleapis.com/maps/api/js?key=mykey&amp;sensor=true" + "&amp;callback=initialize";
              document.body.appendChild(script);
          }
  </code></pre>
  
  <p>It seems that the loadScript does not work!</p>
  
  <pre><code>var mapOptions = {
                  zoom : 13,
                  mapTypeId : google.maps.MapTypeId.ROADMAP
              };
              map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
  </code></pre>
  
  <p>The error jumps out from here. Is anyone who know how to figure it out? I need to use key to get the geolocation service, so I cannot use simple </p>
  
  <pre><code>&lt;script src="https://maps.googleapis.com/maps/api/js?sensor=true"&gt;&lt;/script&gt;
  </code></pre>