title: jQuery Document Ready Function Syntax with Google Maps API
body: <p>I am trying to add the google geocode service to a webpage and am having some JavaScript trouble. When I add the below code without jQuery, I receive the null reference error, but can still occasionally get the service to work. Based on what I'm reading, it is the JS running before the element has loaded and I can wrap this JS into a jQuery function to resolve the issue. However, when I add my code as below, this is error is still popping up and I cannot get the service to run at all. Is there something incorrect in my jQuery syntax? I am very new to JS. Thanks.</p>
  
  <p><strong>"JavaScript runtime error: Unable to get property 'addListener' of undefined or null reference"</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function(){
          google.maps.event.addDomListener(window, 'load', initialize);
          function initialize() {
              var autocomplete = new google.maps.places.Autocomplete(document.getElementById('PostalCodeID'));
              google.maps.evenet.addListener(autocomplete, 'place_changed', function () {
                  var places = autocomplete.getplace();
                  var location = "&lt;b&gt;Location:&lt;/b&gt;" + places.formatted_address + "&lt;br/&gt;";
                  location += "&lt;b&gt;Latitude:&lt;/b&gt;" + places.geometry.location.A + "&lt;br/&gt;";
                  location += "&lt;b&gt;Longitude:&lt;/b&gt;" + places.geometry.location.F + "&lt;br/&gt;";
                  document.getElementById('lblresult').innerHTML = location
              });
          };
          });
  
  &lt;/script&gt;
  </code></pre>