title: google maps api v3 dynamic markers, help getting array to work
body: <p>I am trying to create a google map with javascript api v3. I'm not the best with arrays. the  tag gets pulled in dynamically from another search and outputs the finding in this format. now I need it to take this format and output it to multiple markers on the map. I am having issues getting the array to output correctly. This the the format I would like output from the array ... any help would be greatly appreciated.</p>
  
  <pre><code>var locations = [
    ['Bondi Beach', -33.890542, 151.274856, 4],
    ['Coogee Beach', -33.923036, 151.259052, 5],
    ['Cronulla Beach', -34.028249, 151.157507, 3],
    ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
    ['Maroubra Beach', -33.950198, 151.259302, 1]
  </code></pre>
  
  <p>my code starts here</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt; 
  &lt;head&gt; 
    &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8" /&gt; 
  
    &lt;script src="http://maps.google.com/maps/api/js?sensor=false" 
            type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt; 
  &lt;body&gt;
  
      &lt;markers&gt;
  &lt;marker zip="17507" state="Pennsylvania" city="Bowmansville" address="1363 Bowmansville Rd." county="Lancaster" lng="-76.0134" lat="40.1957" html="Reading Equipment &amp; Distribution (Bowmansville)"&gt;    &lt;/marker&gt;
  &lt;marker zip="18071" state="Pennsylvania" city="Palmerton" address="1226 Little Gap Road" county="Carbon" lng="-75.617" lat="40.8083" html="SMF"&gt;&lt;/marker&gt;
   &lt;marker zip="18020" state="Pennsylvania" city="Bethlehem" address="2706 Brodhead Road" county="Northampton" lng="-75.3696" lat="40.6269" html="Versalift East, LLC (Specialty)"&gt;&lt;/marker&gt;
   &lt;marker zip="19720" state="Delaware" city="New Castle" address="203 Pigeon Point Road" county="New      Castle" lng="-75.5954" lat="39.6733" html="Auto Port, Inc."&gt;&lt;/marker&gt;
       &lt;/markers&gt;
  
     &lt;div id="map" style="width: 500px; height: 400px;"&gt;&lt;/div&gt;
  
    &lt;script type="text/javascript"&gt;
  
     var locations = [];
    var iIndex=0;
  
  
      var markers = document.getElementsByTagName("marker");
       //var locations;
  
      for (var i = 0; i &lt; markers.length; i++) {
            iIndex = i+1;
    }
   // String[] locations = new String[];
      locations.length = iIndex;
  
  
     for (var i = 0; i &lt; markers.length; i++) {
       var name = markers[i].getAttribute("html");
       var address = markers[i].getAttribute("address");
       var city = markers[i].getAttribute("city");
       var state = markers[i].getAttribute("state");
       var zip = markers[i].getAttribute("zip");
        var pointlat = markers[i].getAttribute("lat");
       var pointlng = markers[i].getAttribute("lat");
  
       locations[i] = [];
       locations[i].length = 4;
  
       locations[i][0] = name;
        locations[i][1] = pointlat;
        locations[i][2] = pointlng;
       locations[i][3] = '1';
  
        document.write(locations);
  
      }
  
  
  
        var map = new google.maps.Map(document.getElementById('map'), {
         zoom: 10,
          center: new google.maps.LatLng(-76.0134,40.1957),
         mapTypeId: google.maps.MapTypeId.ROADMAP
       });
  
       var infowindow = new google.maps.InfoWindow();
  
        var marker;
  
        for (var j = 0; j &lt; locations.length; j++) {  
  
  
  
        marker = new google.maps.Marker({
           position: new google.maps.LatLng(locations[j][1], locations[j][2]),
           map: map
         });
  
            google.maps.event.addListener(marker, 'click', (function(marker, j) {
  
          return function() {
            infowindow.setContent(locations[j][0]);
            infowindow.open(map, marker);
          }
        })(marker, j));
           }
  
  
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>