title: Initializing google maps with multiple markers from an array
body: <p>I'm passing 2 arrays into google maps, one for a location (which is geocoded) and another for that location's info window.</p>
  
  <p>Is there any way I can initialize the map and plot all these points at once, or will I have to make a second function to plot more points? Since there are multiple points, I'm not sure how else to do it other than plotting one point, and then making an addition function which loops through the array and plots the rest.</p>
  
  <p>Here's the code.</p>
  
  <p>The two arrays(which I didn't include the code for) are <code>$cityArray</code> and <code>$title</code></p>
  
  <pre><code>function initialize() {
          geocoder = new google.maps.Geocoder();
          latlang = geocoder.geocode( { 'address': 
                                      '&lt;?php echo json_encode($cityArray); ?&gt;'}, 
                                         function(results, status) { 
          //use latlang to enter city instead of coordinates 
          if (status == google.maps.GeocoderStatus.OK) {
              map.setCenter(results[0].geometry.location);
              marker = new google.maps.Marker({
                  map: map,
                  position: results[0].geometry.location
              });
                 google.maps.event.addListener(marker, 'click', 
                                               (function(marker, i) {
                  return function() {
                      infowindow.setContent(
                          '&lt;?php echo json_encode($title); ?&gt;'
                      );
                      infowindow.open(map, marker);
                  }
              })(marker, i));
              markersArray.push(marker);
          }
          else{
              alert("Geocode was not successful for the following reason: " 
                    + status);
          }
      });
      var myOptions = {
          center: latlang, zoom: 4, mapTypeId: google.maps.MapTypeId.SATELLITE,
          navigationControlOptions: {
              style: google.maps.NavigationControlStyle.SMALL
          }
      };
  
      var gm = google.maps;
      map = new google.maps.Map(document.getElementById("main_Content"), 
                                myOptions);
      plotMarkers();
  
  } //end of initialization function
  
  var infowindow = new google.maps.InfoWindow();
  </code></pre>