title: Google Maps API - Drawing Polyline\Flight Path with Lat Lng coordinates in a array
body: <p>Any ideas on how to draw polyline between markers, where the lat lng coordinate are in an array.</p>
  
  <p>Array locations contains coordinates Home, and other locations. I am able to drop markers using the coordinates in the array, the next thing i need to do is do polylines between Home -> Location 1, Home -> Location 2...and so on. </p>
  
  <pre><code>--------------------------
  &lt;script
  var locations =[
              //Starting Point is "Home", and links to other locations"//
              ['Home', 37.774930, -122.419416],
              ['Location-1', 35.689487, 139.691706],
              ['Location-2', 48.856614, 2.352222],
              ['Location-3', -33.867487, 151.206990]
              ]   
  function initMap() {
      var myLatLng = {lat: 12.363, lng: -131.044};
      var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 3,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: {lat:0,lng:0}
      }); 
      var markers = new Array();
      // Add the markers and infowindows to the map
      for (var i = 0; i &lt; locations.length; i++) {  
          var marker = new google.maps.Marker({
          position: new google.maps.LatLng(locations[i][1], locations[i][2]),
          title:locations[i][0],
          map: map
          })
      }
      if (i &gt; 0){
      var startpoint = {"lat": locations[0][1], "long": locations[0][2]};
      var endpoint = {"lat": locations[i][1], "long": locations[i][2]};
      var locationlinks = [   
          new google.maps.LatLng(startpoint.lat, startpoint.long),
          new google.maps.LatLng(endpoint.lat, endpoint.long)
      ];
      var sitepath = new google.maps.Polyline({
          path: locationlinks,
          geodesic: true,
          strokeColor: '#FF0000',
          strokeOpacity: 1.0,
          strokeWeight: 2
      });
      };
      sitepath.setMap(map);
  }   
  &lt;/script&gt;
  &lt;script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBX8Q6FDpU0K9nkVCN7PpxSFybF-2FQem0&amp;callback=initMap"&gt;&lt;/script&gt;    
  </code></pre>
  
  <hr>
  
  <p>As a test changing, locations [i][1], [i][2] to specific array objects works, so it seems like something with the variable that might not be working with array object. </p>
  
  <p>var endpoint = {"lat": locations[2][1], "long": locations[2][2]};</p>
  
  <hr>