title: GoogleMaps API: How to remove multiple markers?
body: <p>I have a function that pins marker in Google Map. This is how it looks:</p>
  
  <pre><code>// Look to draw marker in various coordinates. Pseudo code...
  for(var i = 1; i &lt;= noOfCoordinates; i++){
  
     var lat = latitude[i];
     var long = longitude[i];
  
     drawMarker(lat, long);
  
  };
  
  var drawMarker = function(lat, long){
  // code to draw marker
  
  marker.setMap(map);
  
  };
  </code></pre>
  
  <p>But I also have a function to remove those markers</p>
  
  <pre><code>for(var i = 1; i &lt;= noOfCoordinates; i++){
  
     removeMarker(null);
  
  };
  
  var removeMarker = function(map){
  // code to draw marker
  
  marker.setMap(map);
  
  };
  </code></pre>
  
  <p>drawmarker(); pins/draws marker in google map but removeMarker(); does not remove all markers from the google map, it only removes last one.</p>
  
  <p>I want to remove all marker associated with it, that was drawn from drawMarker(); function. Remove = hide, not delete.</p>
  
  <p>how can I fix this?</p>