title: Google Maps API check if marker exists in multiple bounds
body: <p>I'm trying to check if markers already exist in my boundaries before adding them to the map. I found that the best way to this is by using</p>
  
  <p><code>map.getBounds().contains(marker.getPosition())</code> which returns true if the marker exists on the map and false if it doesn't. So on false, I add the marker to the map. </p>
  
  <p>This works fine however I have multiple boundaries and <code>map.getBounds()</code>seems to get 1 boundary. </p>
  
  <p>The code below sets markers in each boundary in a loop but checks if markers exists in just 1 boundary. How can I check if markers exist in all my boundaries?</p>
  
  <p>I'm checking markers in the last function. </p>
  
  <pre><code>function findPlaces() {      
  
      var boundsArray = new Array(); //my array of multiple boundaries  
  
      for (var i = 0; i &lt; boundsArray.length; i++) {
        var boundary = boundsArray[i];                  
  
        // Perform search over this boundary
        var request = {
          bounds: boundary,
          keyword: document.getElementById("keyword").value
        };
  
        service.nearbySearch(request, callback); 
      }
    });
  }
  
  
  //Returns places and create markers
  function callback(results, status) { 
      if (status == google.maps.places.PlacesServiceStatus.OK) {
         for (var i = 0; i &lt; results.length; i++) {
         createMarker(results[i]);    
      }     
  }   
  
  //create markers
  function createMarker(place) {                          
      var marker = new google.maps.Marker({
         position: place.geometry.location
      });
  
      var onMap = map.getBounds().contains(marker.getPosition());
  
      //if marker is not on the map, add it               
      if (onMap === false) {          
          marker.setMap(map);
      }
  }
  </code></pre>