title: jQuery executes before Google map loads: "map is undefined"
body: <p>Aside from jQuery and Google Maps, I have two scripts included in the head of my page:</p>
  
  <pre><code>&lt;script src="js/map.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="js/site.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>map.js contains the code to initialize my map and also have the following function to place a marker on it:</p>
  
  <pre><code>function placeMarker(marker){
      clearLocations();
  
      var latlng = new google.maps.LatLng(
          parseFloat(marker.lat),
          parseFloat(marker.lng)
      );
  
      var marker = createMarker(latlng);
  
      map.setZoom(14);
      var latLng = marker.getPosition();
      map.setCenter(latLng);          
  
  }
  </code></pre>
  
  <p>When I call <code>placeMarker</code> inside <code>$(document).ready()</code> in site.js, I get the error, 'map is undefined'. However when I call another function in site.js that executes when a button is clicked, <code>placeMarker</code> runs in its callback without a problem:</p>
  
  <pre><code>$.ajax({
      url: 'ajax/json.php',
      dataType: 'json',
      data: 'search_string='+inpMapSearch+'&amp;country='+Country,
      success: function(data) {
          console.log(data);
          placeMarker(data);
      }
  });
  </code></pre>
  
  <p>Does this mean that the <code>placeMarker</code> function call inside <code>$(document).ready()</code> is trying to execute before the map is initialized? How can I run <code>placeMarker</code> after the map is initialized?</p>
  
  <p><strong>=== EDIT ===</strong></p>
  
  <p>As per request here is the code that initializes the map:</p>
  
  <pre><code>google.maps.event.addDomListener(window, 'load', load);
  
  function load() {
      map = new google.maps.Map(document.getElementById("map"), {
          center: new google.maps.LatLng(18.735693,-70.162651),
          zoom: 8,
          mapTypeId: 'roadmap',
          mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
      });
  }
  </code></pre>