google-maps-documentation

Rectangle class

google.maps.Rectangle class

A rectangle overlay.

This class extends MVCObject.

Constructor
Rectangle
Rectangle([opts])
Parameters: 
Create a rectangle using the passed RectangleOptions, which specify the bounds and style.
Methods
getBounds
getBounds()
Parameters:  None
Return Value:  LatLngBounds
Returns the bounds of this rectangle.
getDraggable
getDraggable()
Parameters:  None
Return Value:  boolean
Returns whether this rectangle can be dragged by the user.
getEditable
getEditable()
Parameters:  None
Return Value:  boolean
Returns whether this rectangle can be edited by the user.
getMap
getMap()
Parameters:  None
Return Value:  Map
Returns the map on which this rectangle is displayed.
getVisible
getVisible()
Parameters:  None
Return Value:  boolean
Returns whether this rectangle is visible on the map.
setBounds
setBounds(bounds)
Parameters: 
Return Value:  None
Sets the bounds of this rectangle.
setDraggable
setDraggable(draggable)
Parameters: 
  • draggableboolean
Return Value:  None
If set to true, the user can drag this rectangle over the map.
setEditable
setEditable(editable)
Parameters: 
  • editableboolean
Return Value:  None
If set to true, the user can edit this rectangle by dragging the control points shown at the corners and on each edge.
setMap
setMap(map)
Parameters: 
Return Value:  None
Renders the rectangle on the specified map. If map is set to null, the rectangle will be removed.
setOptions
setOptions(options)
Parameters: 
Return Value:  None
setVisible
setVisible(visible)
Parameters: 
  • visibleboolean
Return Value:  None
Hides this rectangle if set to false.
Events
bounds_changed
function()
Arguments:  None
This event is fired when the rectangle's bounds are changed.
click
function(event)
Arguments: 
This event is fired when the DOM click event is fired on the rectangle.
dblclick
function(event)
Arguments: 
This event is fired when the DOM dblclick event is fired on the rectangle.
drag
function(event)
Arguments: 
This event is repeatedly fired while the user drags the rectangle.
dragend
function(event)
Arguments: 
This event is fired when the user stops dragging the rectangle.
dragstart
function(event)
Arguments: 
This event is fired when the user starts dragging the rectangle.
mousedown
function(event)
Arguments: 
This event is fired when the DOM mousedown event is fired on the rectangle.
mousemove
function(event)
Arguments: 
This event is fired when the DOM mousemove event is fired on the rectangle.
mouseout
function(event)
Arguments: 
This event is fired on rectangle mouseout.
mouseover
function(event)
Arguments: 
This event is fired on rectangle mouseover.
mouseup
function(event)
Arguments: 
This event is fired when the DOM mouseup event is fired on the rectangle.
rightclick
function(event)
Arguments: 
This event is fired when the rectangle is right-clicked on.