title: google maps auto open infoWindow
body: <p>I'm having a problem getting info windows on my google map to auto open I have followed a tutorial here...</p>
  
  <p><a href="https://www.taniarascia.com/google-maps-apis-for-multiple-locations/" rel="nofollow noreferrer">https://www.taniarascia.com/google-maps-apis-for-multiple-locations/</a></p>
  
  <p>Everything is working but I require that the 3 info windows on my map open on page load so visitors see them without having to click the markers.</p>
  
  <p>I have tried several solutions I found here..</p>
  
  <p><a href="https://stackoverflow.com/questions/10342994/google-maps-api-v3-infowindow-automatically-open-on-page-load">Google maps-api v3 InfoWindow automatically open on page load</a></p>
  
  <p>but cant get any of them to work. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function initMap() {
   
   var scorrier = {
    info: '&lt;center&gt;&lt;img src="assets/images/ge-logo-300px.jpg"&gt;&lt;br&gt;&lt;br&gt;\
       &lt;strong&gt;The Great Estate&lt;/strong&gt;&lt;br&gt;\
       Scorrier House&lt;br&gt;Cornwall, TR16 5AU&lt;br&gt;\
       &lt;strong&gt;&lt;a href="https://www.google.co.uk/maps/dir/Bristol/Scorrier+House,+Scorrier,+Redruth+TR16+5AU/@50.8495256,-5.0243318,8z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x4871836681b3d861:0x8ee4b22e4b9ad71f!2m2!1d-2.58791!2d51.454513!1m5!1m1!1s0x486b18b9cddd326b:0x25c89b140e8bf264!2m2!1d-5.1924054!2d50.2501818" target="_blank" style="color:red"&gt;Directions to The Great Estate&lt;/a&gt;&lt;/center&gt;&lt;/strong&gt;',
    lat: 50.2501818,
    long: -5.1924054
   };
  
   var redruth = {
    info: '&lt;strong&gt;Redruth Train Station&lt;/strong&gt;&lt;br&gt;\
       Redruth&lt;br&gt;Cornwall, TR15 2AB&lt;br&gt;\
       &lt;strong&gt;&lt;a href="https://www.google.co.uk/maps/dir/TR15+2AB,+Station+Rd,+Redruth/Scorrier+House,+Scorrier,+Redruth+TR16+5AU/@50.2428949,-5.2183829,15z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x486b1f5fb5f4a7ed:0xfa94523df7169fe6!2m2!1d-5.2258756!2d50.2332886!1m5!1m1!1s0x486b18b9cddd326b:0x25c89b140e8bf264!2m2!1d-5.1924054!2d50.2501818?shorturl=1" target="_blank" style="color:red"&gt;Directions to The Great Estate&lt;/a&gt;&lt;/strong&gt;',
    lat: 50.233210,
    long: -5.225936
   };
  
   var truro = {
    info: '&lt;strong&gt;Truro Train Station&lt;/strong&gt;&lt;br&gt;\r\
       Station Road, Truro&lt;br&gt; Cornwall, TR1 3HH&lt;br&gt;\
       &lt;strong&gt;&lt;a href="https://www.google.co.uk/maps/dir/Truro,+Station+Road,+Truro,+Cornwall+TR1+3HH/Scorrier+House,+Scorrier,+Redruth+TR16+5AU/@50.2646882,-5.1661898,13z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x486b17b40079af5d:0x9752f63a0a1484f8!2m2!1d-5.0641465!2d50.2640872!1m5!1m1!1s0x486b18b9cddd326b:0x25c89b140e8bf264!2m2!1d-5.1924054!2d50.2501818?shorturl=1" target="_blank" style="color:red"&gt;Directions to The Great Estate&lt;/a&gt;&lt;/strong&gt;',
    lat: 50.264087,
    long: -5.064146
   };
  
   var locations = [
        [scorrier.info, scorrier.lat, scorrier.long, 0],
        [redruth.info, redruth.lat, redruth.long, 1],
        [truro.info, truro.lat, truro.long, 2],
      ];
  
   var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 13,
    scrollwheel: false,
    gestureHandling: 'cooperative',
    center: new google.maps.LatLng(50.2501818, -5.1924054),
    mapTypeId: google.maps.MapTypeId.ROADMAP
   });
  
   var infowindow = new google.maps.InfoWindow({});
  
   var marker, i;
  
   for (i = 0; i &lt; locations.length; i++) {
    marker = new google.maps.Marker({
     position: new google.maps.LatLng(locations[i][1], locations[i][2]),
     map: map
    });
    
    
    /* Not sure how to trigger all info windows to open on page load not click????
    google.maps.event.addDomListener(window, 'load', initialize);
    */
  
    google.maps.event.addListener(marker, 'click', (function (marker, i) {
     return function () {
      infowindow.setContent(locations[i][0]);
      infowindow.open(map, marker);
     }
    })(marker, i));
    
    
   }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="map"&gt;&lt;/div&gt;
   &lt;script src="assets/js/map.js"&gt;&lt;/script&gt;
    &lt;script async defer 
       src="https://maps.googleapis.com/maps/api/js?MYKEYISHERE&amp;callback=initMap"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>