title: Issue on Removing Markers From Map
body: <p>Can you please take a look at <a href="http://iomhumanitarian.atwebpages.com/map.html" rel="nofollow">this Link</a> and let me know why I am not able to remove the Markers from the Map? I am getting this error message:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Object [object Array] has no method 'setMap'</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  $( "#trg" ).click(function() {
   $.ajax({
      // type: "POST",
      url: 'SO_20131215_data.json.txt',
      dataType: 'json',
  
      success: function(data){ 
        locations.length = 0;
        for (p = 0; p &lt; data.markers.length; p++) {
          locations.push(Array(data.markers[p].latitude,data.markers[p].longitude));
          // To add the marker to the map, use the 'map' property
          var marker = new google.maps.Marker({
            position: new google.maps.LatLng(data.markers[p].latitude,data.markers[p].longitude),
            map: map,
            title:"marker "+p
          });
        }
      },
      error: function (xhr,status,errorStr) {
        alert("status="+status+", error="+errorStr);
      }
  
    }); 
  
  });
    function removeMarkers() {
              for (i = 0; i &lt; locations.length; i++) {
                  locations[i].setMap(null)
              }
          }
  
    $('#remover').click(function () {
              removeMarkers();
          });
  </code></pre>