title: Manipulating JSON data to create javascript array of lat/lngs in Google Maps API V3
body: <p>I'm trying to use lat/lng values retrieved from MySQL to create an array of waypoints for use in the GMaps API. I have the code below but with my limited javascript knowledge am struggling to push this retrieved data into a javascript array to define as the waypoints data.</p>
  
  <p>I've looked at a few online examples and so far I have managed to get a parsing script to retrieve the data with no problems and call this within the page I have the maps instantiated on:</p>
  
  <pre><code>makeRequest('parsedata.php', function(data) {
  
              var data = JSON.parse(data.responseText);
  
              for (var i = 0; i &lt; data.length; i++) {
                  displayLocation(data[i]);
              }
  
          });
  </code></pre>
  
  <p>The parsedata.php code:</p>
  
  <pre><code>&lt;?php     
      include 'session.php';
  
     $query = "SELECT itinerary_link.itineraryID, itinerary_link.coursesID, itinerary_courses.coursename, 
  courses.lat, courses.lng FROM itinerary_link LEFT JOIN
   itinerary_courses ON itinerary_link.coursesID = itinerary_courses.coursesID LEFT JOIN 
  courses ON courses.coursename = itinerary_courses.coursename WHERE itineraryID=6 ORDER BY coursename";
     $result = mysqli_query($dbc, $query);
     $rows = array();
     while ($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
     }
     print json_encode( $rows );
  ?&gt;
  </code></pre>
  
  <p>And sample output from this:</p>
  
  <pre><code>[{"itineraryID":"6","coursesID":"20","coursename":"Carnoustie Championship Course","lat":"56.497414","lng":"-2.720531"},{"itineraryID":"6","coursesID":"21","coursename":"Troon Old Course","lat":"55.534203","lng":"-4.642833"}]
  </code></pre>
  
  <p>Basically I can't work out how to manipulate this output to create the required javascript array of lat/lngs to feed in as the waypoints for a directions service instance I have running on the page.</p>
  
  <p>As always, any pointers much appreciated. Cheers.</p>