title: Loop through array for map
body: <p>I need help looping through an array and finishing this code. My array is created from an XML file. The XML file contains meeting location data to be plotted on a map. The array ends up looking like this:</p>
  
  <pre><code>markerfilter[0].name
  markerfilter[0].address
  markerfilter[0].Meeting_Type
  etc...
  markerfilter[1].name
  markerfilter[1].address
  markerfilter[1].Meeting_Type
  etc...
  </code></pre>
  
  <p>Right now all the markers plot on the map. I need to loop through the array and filter it based on some variables I setup. This is my attempt at looping through the array:</p>
  
  <pre><code>for (var i = 0; i &lt; markerfilter.length; i++) {
      if (markerfilter[i].Meeting_Type==type&amp;&amp;markerfilter[i].Day_of_Meeting==day&amp;&amp;markerfilter[i].Time_of_Meeting==time){
          //need to plot the points on the map here
          }else{
          //need to show blank map
          }
      }
  </code></pre>
  
  <p>Here is my entire code. I don't even know if the loop is in the right place or if other pieces of the code need to go inside the loop. Any help??</p>
  
  <pre><code>$(document).ready(function() {
      $("#map").css({
      height: 500,
      width: 600
  });
  var myLatLng = new google.maps.LatLng(43.653823, -79.382843);
  MYMAP.init('#map', myLatLng, 11);
  
  $("#showmarkers").click(function(e){
      MYMAP.placeMarkers('include/xml.php');
  });
  });
  
  var MYMAP = {
  map: null,
  bounds: null
  }
  
  MYMAP.init = function(selector, latLng, zoom) {
  var myOptions = {
      zoom:zoom,
      center: latLng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  this.map = new google.maps.Map($(selector)[0], myOptions);
  this.bounds = new google.maps.LatLngBounds();
  }
  
  var markerfilter = [];
  MYMAP.placeMarkers = function(filename) {
  $.get(filename, function(xml){
      $(xml).find("marker").each(function(){
          var name = $(this).find('name').text();
          var address = $(this).find('address').text();
          var address2 = $(this).find('address2').text();
          var Meeting_Type = $(this).find('Meeting_Type').text();
          var Time_of_Meeting = $(this).find('Time_of_Meeting').text();
          var Day_of_Meeting = $(this).find('Day_of_Meeting').text();
          var Open_Meeting = $(this).find('Open_Meeting').text();
          var Wheelchair = $(this).find('Wheelchair').text();
          var ASL = $(this).find('ASL').text();
          var Comments = $(this).find('Comments').text();
          // create a new LatLng point for the marker
          var lat = $(this).find('lat').text();
          var lng = $(this).find('lng').text();
          var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
  
          var markerdata = {};
          $(this).children().each(function() {
              markerdata[this.tagName] = $(this).text();
          });
          markerfilter.push(markerdata);
  
          var MeetingType = document.getElementById("Meeting_Type");
          var type = MeetingType.options[MeetingType.selectedIndex].text;
          var DayofMeeting = document.getElementById("Day_of_Meeting");
          var day = DayofMeeting.options[DayofMeeting.selectedIndex].text;
          var TimeofMeeting = document.getElementById("Time_of_Meeting");
          var time = TimeofMeeting.options[TimeofMeeting.selectedIndex].text;
  
          for (var i = 0; i &lt; markerfilter.length; i++) {
          if (markerfilter[i].Meeting_Type==type&amp;&amp;markerfilter[i].Day_of_Meeting==day&amp;&amp;markerfilter[i].Time_of_Meeting==time){
              markerfilter[i].setMap(MYMAP.map);
              }else{
              markerfilter[i].setMap(null);
              }
          }
  
          // extend the bounds to include the new point
          MYMAP.bounds.extend(point);
  
          var marker = new google.maps.Marker({
              position: point,
              map: MYMAP.map
          });
  
          var infoWindow = new google.maps.InfoWindow();
          var html='&lt;b&gt;&lt;u&gt;'+name+'&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;'+address2+'&lt;br /&gt;'+address+'&lt;br /&gt;'+Meeting_Type+',&amp;nbsp'+Time_of_Meeting+',&amp;nbsp'+Day_of_Meeting+'&lt;br /&gt;Open Meeting:&amp;nbsp'+Open_Meeting+'&lt;br /&gt;Wheelchair Accessible:&amp;nbsp'+Wheelchair+'&lt;br /&gt;ASL:&amp;nbsp'+ASL+'&lt;br /&gt;Comments:&amp;nbsp'+Comments;
          google.maps.event.addListener(marker, 'click', function() {
              infoWindow.setContent(html);
              infoWindow.open(MYMAP.map, marker);
          });
          MYMAP.map.fitBounds(MYMAP.bounds);
      });
  });
  console.log(markerfilter);
  }
  </code></pre>
  
  <p>Right now when I run my current, firebug tells me:
  markerfilter[i].setMap(null) is not a function.</p>