title: Async load of Earth at Night map
body: <p>I would like to use this custom map when loading via JS API 3: <a href="https://earthbuilder.google.com/10446176163891957399-13737975182519107424-4/mapview/" rel="nofollow">https://earthbuilder.google.com/10446176163891957399-13737975182519107424-4/mapview/</a></p>
  
  <p>I'm not sure how to use the provided API code addLayersToMap(map) and can't find that function anywhere in the documentation. I'm sure it's as easy as calling that function on the map, but that didn't seem to get me anywhere.</p>
  
  <p>Here's my embed code:</p>
  
  <pre><code>        &lt;script type="text/javascript"&gt; 
              function initialize() {
                var mapOptions = {
                  zoom: 14,
                  center: new google.maps.LatLng(32.26555,-110.961386)
                };
  
                var map = new google.maps.Map(document.getElementById('map-canvas'),
                  mapOptions);
  
                var mapsEngineLayer = new google.maps.visualization.MapsEngineLayer({
                  layerId: '06673056454046135537-08896501997766553811',
                  map: map
                });
              }
              function addLayersToMap(map) {
                // Handles to the layers created.  var layers = [];
                var layerKeys = [
                ""
                ];
  
                for (var i = 0; i &lt; layerKeys.length; ++i) {
                  layers.push(new google.maps.visualization.MapsEngineLayer({
                    mapId: "10446176163891957399-13737975182519107424-4",
                    layerKey: layerKeys[i],
                    map: map
                  }));
                }
                return layers;
              }
  
              function loadScript()
              {
                  var script = document.createElement("script");
                  script.type = "text/javascript";
                  script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyDOkhCBaoEKOhnpEJorFi83JSb0vIEkRg4&amp;sensor=false&amp;callback=initialize";
                  document.body.appendChild(script);
              }
              window.onload = loadScript();
          &lt;/script&gt;
  </code></pre>