how to draw a polygon in google map API using array of coordinates?
<p>I am new to JavaScript and I am trying to use google map API to draw a polygon.  The default paths in the google.maps.Polygons function accept JSON with the following format: </p>

<pre><code> var trianglecoords=[
           {lat: 18.466, lng: -66.518},
           {lat: 18.466, lng: -66.118},
           {lat: 18.166, lng: -66.118},
                 ];
</code></pre>

<p>however my format is: </p>

<pre><code>var trianglecoords=[
                   [18.466,-66.518],
                   [18.466,-66.118],
                   [18.166,-66.118],
                         ];
</code></pre>

<p>using my format I cannot see the triangle in the map. can anyone help me? </p>

<p>here is my code:</p>

<pre><code>function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 5,
    center: {lat: 24.886, lng: -70.268},
    mapTypeId: google.maps.MapTypeId.TERRAIN
  });

  // Define the LatLng coordinates for the polygon's path.
  var triangleCoords = [
    [25.774, -80.190],
    [18.466, -66.118],
    [32.321,-64.757],
    [25.774, -80.190]
  ];

  // Construct the polygon.
  var bermudaTriangle = new google.maps.Polygon({
    paths: triangleCoords,
    strokeColor: '#FF0000',
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: '#FF0000',
    fillOpacity: 0.35
  });
  bermudaTriangle.setMap(map);
}
</code></pre>