title: Pass data to callback when asynchronously loading google maps V3
body: <p>I am <a href="https://developers.google.com/maps/documentation/javascript/tutorial#asynch">loading the google maps API asynchronously</a> which allows you to define a callback to execute when the API loads. Is there any way I can pass arguments to the callback?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's the code I'm working with. I have a global object called <code>master</code> storing the following functions.</p>
  
  <pre><code>/**
   * Load the Google Maps API
   * https://developers.google.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API
   */
  loadGoogleMaps: function(){
      var googleMaps = document.createElement("script");
      googleMaps.type = "text/javascript";
      googleMaps.src = "http://maps.googleapis.com/maps/api/js?key=[MYAPIKEY]&amp;sensor=false&amp;callback=master.mapInit";
      document.body.appendChild(googleMaps);
  }
  </code></pre>
  
  <p>I want to be able to pass an array of locations into <code>mapInit</code> so I can add markers to the map when it gets initialized. I'd also like to be able to globally access the reference to the map so I can modify the map after its creation.</p>
  
  <pre><code>/**
   * Initialize the map
   */
  mapInit: function(){
  
      // Default map options
      var mapOptions = {
          zoom: 4,
          center: new google.maps.LatLng( 40, -95 ),
          mapTypeId: google.maps.MapTypeId.ROADMAP
      }
  
      // Create map
      var map = new google.maps.Map( document.getElementById("map"), mapOptions );
  
  }
  </code></pre>