Return to Snippet

Revision: 46843
at May 26, 2011 15:09 by sneaks


Initial Code
// init
        // Plot two markers to represent the Rectangle's bounds.
        marker1 = new google.maps.Marker({
          map: map,
          position: new google.maps.LatLng(65, -10),
          draggable: true,
          title: 'Drag me!'
        });
        marker2 = new google.maps.Marker({
          map: map,
          position: new google.maps.LatLng(71, 10),
          draggable: true,
          title: 'Drag me!'
        });
        
        // Allow user to drag each marker to resize the size of the Rectangle.
        google.maps.event.addListener(marker1, 'drag', redraw);
        google.maps.event.addListener(marker2, 'drag', redraw);
        
        // Create a new Rectangle overlay and place it on the map.  Size
        // will be determined by the LatLngBounds based on the two Marker
        // positions.
        rectangle = new google.maps.Rectangle({
          map: map
        });
        redraw();





 
 
       function redraw() {
        var latLngBounds = new google.maps.LatLngBounds(
          marker1.getPosition(),
          marker2.getPosition()
        );
        rectangle.setBounds(latLngBounds);
		//console.log(marker1.getPosition()+","+marker2.getPosition());
      }

Initial URL

                                

Initial Description

                                

Initial Title
google maps v3 rectangle

Initial Tags
google, api

Initial Language
JavaScript