title: Remove Rectangle from Google Maps
body: <p>I'm using Google Maps v3 (javascript). I draw a rectangle in the following way when I load my map:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    // Global variables
    var map;
  
    /**
     * Called on the initial page load.
     */
    function init() {
  
      map = new google.maps.Map(document.getElementById('map'), {
        'zoom': 6,
        'center': new google.maps.LatLng(41.87194,12.567379999999957),
        'mapTypeId': google.maps.MapTypeId.ROADMAP
      });
  
      //Region Overlay
      var latLng1;
      var latLng2;
  
      &lt;?php foreach ($this-&gt;arrRegion as $region) { ?&gt;
          latLng1 = new google.maps.LatLng(&lt;?php echo $region['boundLat1_region']; ?&gt;,&lt;?php echo $region['boundLng1_region']; ?&gt;);
          latLng2 = new google.maps.LatLng(&lt;?php echo $region['boundLat2_region']; ?&gt;,&lt;?php echo $region['boundLng2_region']; ?&gt;);
          redraw(latLng1,latLng2);
      &lt;?php }?&gt;
  
    }
  
    /**
     * Updates the Rectangle's bounds to resize its dimensions.
     */
    function redraw(latLng1,latLng2) {
      var latLngBounds = new google.maps.LatLngBounds(latLng1,latLng2);
       // Create a new Rectangle overlay
      var rectangle = new google.maps.Rectangle({map: map, bounds: latLngBounds});
    }
  
    // Register an event listener to fire when the page finishes loading.
    google.maps.event.addDomListener(window, 'load', init);
  &lt;/script&gt;
  </code></pre>
  
  <p>Now, my goal is to remove the rectangle. I try to used map.clear but it didn't work. Any suggestion?</p>