title: Google Maps google.maps.places.PlacesService typeerror undefined
body: <p>Following the code nearly exactly from: <a href="https://developers.google.com/maps/documentation/javascript/places#TextSearchRequests" rel="nofollow">https://developers.google.com/maps/documentation/javascript/places#TextSearchRequests</a></p>
  
  <p>When</p>
  
  <pre><code>service = new google.maps.places.PlacesService(map);
  </code></pre>
  
  <p>is called, the console gives me an undefined type error:</p>
  
  <pre><code>util.js:22 Uncaught TypeError: Cannot read property 'innerHTML' of undefined
  </code></pre>
  
  <p>My code is below. Anyone know what is happening?</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDo5LxyVUv5EwGQBwaveIF4d0MaIVD_Dd8&amp;libraries=places"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>function initMap(userLocation) {
      map = new google.maps.Map(document.getElementById('map'), {
          center: userLocation,
          zoom: radius
      });
  
      infowindow = new google.maps.InfoWindow();
  }
  
  function textSearch(query) {
      var service;
  
      var request = {
          location: userLocation,
          query: query
      };
  
      service = new google.maps.places.PlacesService(map);
      service.textSearch(request, cb);
  }
  
  function cb(results, status) {
      if (status == google.maps.places.PlacesServiceStatus.OK) {
          for (var i = 0; i &lt; results.length; i++) {
              var place = results[i];
              // createMarker(results[i]);
              console.log(place);
          }
      }
  }
  
  initMap(userLocation); // userLocation is a latLong obj, set elsewhere in the code.
  textSearch('movies');
  </code></pre>