title: Put Google Maps Javascript Function Into External File
body: <p>I need to put my google maps javascript into an external javascript file and I am having some issues doing this. The code below is from my working HTML file, I have tried copying the function into an external file including the script src tags and DomListener. The issue I am having is with the DomListener and it not being able to load its parameters properly. I was wondering if you could please assist me with what I need to put in the external file and what I need to call in the HTML file to execute my script?</p>
  
  <p>Thank you very much,
  Anthony</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;link href="mystyle.css" rel="stylesheet" type="text/css" /&gt;
  &lt;meta name="Park Map Brisbane"
      content="initial-scale=1.0, user-scalable=no"&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Info windows&lt;/title&gt;
  &lt;style&gt;
  #map-canvas {
      height: 800px;
      width: 800px;
      text-align: center;
      margin-left: 51px;
      margin: 0px;
      padding: 0px
  }
  
  .gm-style-iw {
      height: 100% !important;
      overflow: hidden !important;
  }
  &lt;/style&gt;
  &lt;script
      src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
  &lt;script&gt;
      function initialize() {
          var myLatlng1 = new google.maps.LatLng(-25.363882, 150.044922);
          var myLatlng2 = new google.maps.LatLng(-25.363882, 152.044922);
          var mapOptions = {
              zoom : 6,
              center : myLatlng1
          };
  
          var map = new google.maps.Map(document.getElementById('map-canvas'),
                  mapOptions);
  
          var contentString1 = 'Mott Park'
          var contentString2 = 'Kilpa Park'
  
          var infowindow = new google.maps.InfoWindow({});
  
          var marker1 = new google.maps.Marker({
              position : myLatlng1,
              map : map,
              title : 'Park'
          });
          var marker2 = new google.maps.Marker({
              position : myLatlng2,
              map : map,
              title : 'Water'
          });
          google.maps.event.addListener(marker1, 'click', function initialize() {
              infowindow.close();//hide the infowindow
              infowindow.setContent(contentString1);//update the content for this marker
              infowindow.open(map, marker1);
  
          });
          google.maps.event.addListener(marker2, 'click', function initialize() {
              infowindow.close();//hide the infowindow
              infowindow.setContent(contentString2);//update the content for this marker
              infowindow.open(map, marker2);
          });
      }
  
      google.maps.event.addDomListener(window, 'load', initialize);
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="map-canvas"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>