title: Basic JavaScript array from an array of ruby arrays containing floats
body: <p>I am trying to make a basic heatmap using Google Maps API - <a href="https://developers.google.com/maps/documentation/javascript/heatmaplayer" rel="nofollow noreferrer">https://developers.google.com/maps/documentation/javascript/heatmaplayer</a></p>
  <p>I have an array of arrays of map coordinates I am passing from my rails controller like so:</p>
  <pre><code>@coordinates = [[51.60382, 0.02785], [51.6038, 0.02785], [51.60401, 0.02799], [51.60389, 0.02789], [51.60389, 0.02789], [51.60389, 0.02789], [51.60389, 0.02789], [51.60389, 0.02789], [51.60385, 0.02785], [51.60385, 0.02785], [51.60386, 0.02785], [51.60386, 0.02785], [51.60387, 0.02783], [51.60387, 0.02781]]
  </code></pre>
  <p>For each of these arrays I want to create a Google maps LatLng JavaScript object like so:</p>
  <pre><code>    new google.maps.LatLng(37.782551, -122.445368),
  </code></pre>
  <p>I can get the array of coordinate arrays through to the view ok however am struggling to create an array of the objects that look like that above.</p>
  <p>My most recent attempt:</p>
  <pre><code>   var coordinatesArray = &lt;%= @coordinates %&gt;;
  
        function getPoints() {
          function coordinatesArrayTwo () {
            var coordinatesArrayNew = coordinatesArray.map( c =&gt; new google.maps.LatLng(c[0], c[1]) );
            return coordinatesArrayNew;
          };
  
          return[coordinatesArrayTwo()]
  </code></pre>
  <p>The idea being to iterate through the array of arrays and create a new object inserting the array coordinates...</p>
  <p>However this does not seem to work and I am having a hard time viewing what it is actually returning.</p>
  <p>I have a feeling it is fairly basic but could anyone help with this?</p>
  <p>Thanks</p>