title: How to modify content of an array in Javascript
body: <p>I'm using the Google Maps API to create some zones on a map. I stored the geodata in a database and I get it through Ajax. </p>
  
  <p>Problem is that API wants the data as an object like : </p>
  
  <pre><code>var myHome = { "lat" : "44.767778" , "long" : "-93.2775" };
  </code></pre>
  
  <p>So I need to put in the array the {"lat" : and "long : ... };</p>
  
  <p>How could I do that ?</p>
  
  <hr>
  
  <p>Here is what I did with your help. I've got no error but nothing appears on the map. I used the example with BermudaTriangle from the API like a model : <a href="https://developers.google.com/maps/documentation/javascript/examples/polygon-autoclose" rel="nofollow">https://developers.google.com/maps/documentation/javascript/examples/polygon-autoclose</a></p>
  
  <pre><code>    $.get(
      "getZones.php", //Get geodata from database
      function(data) {
        locZone = data;
        var reg=new RegExp("[/]+", "g"); //Separate points of the zone
        var tableau=locZone.split(reg);
        for (var i=0; i&lt;tableau.length; i++) {
            points = new google.maps.LatLng(tableau[i]);
            coords.push(points);//Put the coordinates in a tab
          }
        var zone = new google.maps.Polygon({
          paths: coords, //Use the tab like in the example from API
          strokeColor: '#FF0000',
          strokeOpacity: 0.8,
          strokeWeight: 3,
          fillColor: '#FF0000',
          fillOpacity: 0.35
        });
        zone.setMap(map);
      }
    );
  </code></pre>
  
  <hr>
  
  <p>That's okay I just rewrote the loop : </p>
  
  <pre><code>for (var i=0; i&lt;tableau.length; i++) {
        var b=tableau[i].split(","); //Separate lat &amp; lng
        points=new google.maps.LatLng(parseFloat(b[0]), parseFloat(b[1])); //Convert data into float type
        coords.push(points); 
      }
  </code></pre>