title: Google Maps polyline array from mySQL
body: <p>I'm using the guide on the api pages (<a href="https://developers.google.com/maps/articles/phpsqlajax_v3" rel="nofollow">https://developers.google.com/maps/articles/phpsqlajax_v3</a>) to read in markers from a mySQL db via an XML file. </p>
  
  <p>I'm unsure how to get the polyline path from the xml file, if possible. I can get markers to work correctly, however.</p>
  
  <p>My existing code is here:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      //&lt;![CDATA[
          function load() {       
              //Retrieve generated xml file containing marker data
                  downloadUrl("phpsqlajax_genxml.php", function(data) {
              var xml = data.responseXML;
              var markers = xml.documentElement.getElementsByTagName("marker");
  
              //Create map, find center from marker array
              var map = new google.maps.Map(document.getElementById("map"), {
                  center: new google.maps.LatLng(parseFloat(markers[0].getAttribute("latitude")),
                      parseFloat(markers[0].getAttribute("longitude"))),
                  zoom: 5,
                  scaleControl:true,
                  mapTypeId:google.maps.MapTypeId.ROADMAP,
                  });
                  var infoWindow = new google.maps.InfoWindow;
              var imgnum=1;
              //Loop through markers array, using its length to find points and create markers on map
              for (var i = 0; i &lt; markers.length; i++) {
                  var point = new google.maps.LatLng(
                      parseFloat(markers[i].getAttribute("latitude")),
                      parseFloat(markers[i].getAttribute("longitude")));
                  var image = new google.maps.MarkerImage('http://chart.apis.google.com/chart?chst=d_map_pin_letter&amp;chld=' + imgnum + '|FF0000|000000'
  ); 
                  imgnum++;               
                  var marker = new google.maps.Marker({
                      map: map,
                          position: point,
                      icon: image,                
                  });       
  
              }
  
              //var polylinep = [new google.maps.LatLng(parseFloat(markers[0].getAttribute("latitude")), parseFloat(markers[0].getAttribute("longitude"))),new google.maps.LatLng(parseFloat(markers[1].getAttribute("latitude")), parseFloat(markers[1].getAttribute("longitude")))];    
  
              for(var i = 0; i &lt; markers.length; i++){
                  new google.maps.LatLng(parseFloat(markers[i].getAttribute("latitude")), parseFloat(markers[i].getAttribute("longitude")));
              }   
  
              var polyline = new google.maps.Polyline({
                  path: polylinep,
                  geodesic: true,
                  strokeColor: "#FF0000",
                  strokeOpacity: 0.8,
                  strokeWeight: 2
              });     
  
              polyline.setMap(map);
  
              });
          }
  
          //Infowindow creator - unimplemented
          function bindInfoWindow(marker, map, infoWindow, html) {
              google.maps.event.addListener(marker, 'click', function() {
                  infoWindow.setContent(html);
                  infoWindow.open(map, marker);
                  });
          }
  
          //Get xml file
          function downloadUrl(url, callback) {
                var request = window.ActiveXObject ?
                new ActiveXObject('Microsoft.XMLHTTP') :
                new XMLHttpRequest;
  
                  request.onreadystatechange = function() {
                  if (request.readyState == 4) {
                      request.onreadystatechange = doNothing;
                      callback(request, request.status);
                  }
                  };
  
                  request.open('GET', url, true);
                  request.send(null);
              }
  
          function doNothing() {}
  
              //]]&gt;
  
          &lt;/script&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: Here is the xml file generated using the PHP script:</p>
  
  <pre><code>&lt;markers&gt;
  &lt;marker latitude="-4.06865" longitude="52.3994"/&gt;
  &lt;marker latitude="-4.06865" longitude="52.3994"/&gt;
  &lt;marker latitude="-4.06493" longitude="52.4162"/&gt;
  &lt;marker latitude="-4.06493" longitude="52.4162"/&gt;
  &lt;/markers&gt;
  </code></pre>