title: Uncaught ReferenceError: google is not defined when trying to use Google Places API without a map
body: <p>I know this is a really common error, but I read all the other "Uncaught ReferenceError: google is not defined" questions and none of them helped me fix it.  I am using the Google Places API but my application does not use a map so I referred to <a href="https://stackoverflow.com/questions/14343965/google-places-library-without-map">this question</a> to figure that out.  </p>
  
  <p>Many of the answers talked about loading the api script asyncronously before everything else, and the order of the scripts matters, but I don't think that's my issue.  I followed the example in the <a href="https://developers.google.com/maps/documentation/javascript/examples/place-search" rel="nofollow">Places API Documentation</a> so I don't know what I am doing wrong.  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"/&gt;
      &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Places Near Chicago&lt;/h1&gt;
      &lt;div id="list"&gt;&lt;/div&gt;
      &lt;script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&amp;libraries=places" async defer&gt;&lt;/script&gt;
      &lt;script&gt;
      var service = new google.maps.places.PlacesService(document.getElementById('list'));
      var request = {
              location: new google.maps.LatLng(41.8781136, -87.6297982),
              radius: 5
      };
  
      service.search(request, callback);
      function callback(results, status){
              if(status == google.maps.places.PlacesServiceStatus.OK){
                      console.log(status);
                      for (var i = 0; i &lt; results.length; i++) {
                              console.log(results[i].name, results[i].types);
                      }
              }
      };
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The issue is specifically with the line </p>
  
  <pre><code>var service = new google.maps.places.PlacesService(document.getElementById('list'));
  </code></pre>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong> I updated my code as per Jeff's suggestion and still get the same error.</p>