class DragZoomControl

This class lets you add a control to the map which, when clicked, will let the map user zoom by dragging a rectangle on the map. It extends GControl.

Constructor

Constructor Description
DragZoomControl(opts_boxStyle, opts_other, opts_callbacks ) Creates a DragZoomControl with the specified options (hashes). All parameters are required, even if empty hashes.

Methods

Methods Return Value Description
saveMapContext(text) None The map state is pushed onto the context stack, the backButtonHTML is set to 'text', and the back button is made visible.
initiateZoom() None A DragZoom operation is initiated as if the user had clicked the DragZoom button. For use in custom map controls.
initiateZoomBack() None A DragZoom back operation is initiated as if the user had clicked the DragZoom back button. For use in custom map controls.

Events

Events Arguments Description
addoverlay overlay This event is fired when the mouse button is released after a zoom rectangle has been specified. The GPolyline representing the frame around the selected area is passed as the overlay argument.
removeoverlay overlay This event is fired when the GPolyline representing the frame around the selected area (passed as the overlay argument) is removed. This occurs overlayRemoveTime milliseconds after the area was specified.

class DragZoomBoxStyleOptions

Instances of this class are used in the opts_boxStyle argument to the constructor of the DragZoomControl class. There is no constructor for this class. Instead, this class is instantiated as a javascript object literal.

Properties

As the name of this class indicates, all properties are optional.

Properties Type Description
opacity Number Opacity of the veil from 0-1. Default is 0.2.
fillColor String Hex value of fill color. Default is "#000".
border String CSS-style declaration of border. Default is "2px solid blue".

class DragZoomOtherOptions

Instances of this class are used in the opts_other argument to the constructor of the DragZoomControl class. There is no constructor for this class. Instead, this class is instantiated as a javascript object literal.

Properties

As the name of this class indicates, all properties are optional.

Properties Type Description
buttonHTML String The zoom button HTML in non-activated state. Default is "zoom..".
buttonStartingStyle Object A hash of CSS styles for the zoom button which are common to both un-activated and activated state. Default is {width: '52px', border: '1px solid black', padding: '2px'}.
buttonStyle Object A hash of CSS styles for the zoom button which will be applied when the button is in un-activated state. Default is {background: '#FFF'}.
buttonZoomingHTML String HTML which is placed in the zoom button when the button is activated. Default is "Drag a region on the map".
buttonZoomingStyle Object A hash of CSS styles for the zoom button which will be applied when the button is activated. Default is {background: '#FF0'}.
backButtonHTML String HTML which is placed in the back button when the button is activated. Default is "Drag Zoom Back".
backButtonStyle Object A hash of CSS styles for the back button which will be applied when the button is activated. Default is {background: '#FFF', display: 'none'}.
backButtonEnabled Boolean Determines whether or not the back button functionality is turned on. Default is false.
overlayRemoveTime Number The number of milliseconds to wait before removing the rectangle indicating the zoomed-in area after the zoom has happened. Default is 6000.
stickyZoomEnabled Boolean Whether or not the control stays in "zoom mode" until turned off. When true, the user can zoom repeatedly, until clicking on the zoom button again to turn zoom mode off. Defaults to false.
rightMouseZoomOutEnabled Boolean Whether to zoom out when a drag with the right mouse button occurs. If enabled, dragging with the right button tries to find a zoom level to fit the current visible extent of the map into the size of the dragged box. Defaults to false.

class DragZoomCallbacks

Instances of this class are used in the opts_callbacks argument to the constructor of the DragZoomControl class, and allow you to set callback functions for various DragZoom events. There is no constructor for this class. Instead, this class is instantiated as a javascript object literal.

Properties

As the name of this class indicates, all properties are optional.

Properties Type Description
buttonclick Function Called when DragZoom is activated by clicking on the DragZoom button or by calling the buttonclick() method.
dragstart Function Called when user starts to drag a rectangle. Callback args are x,y -- the pixel values, relative to the upper-left-hand corner of the map, where the user began dragging.
dragging Function Called repeatedly while the user is dragging. Callback args are startX,startY, currentX,currentY -- the pixel values of the start of the drag, and the current drag point, respectively.
dragend Function Called when the user releases the mouse button after dragging the rectangle. Callback args are: NW {GLatLng}, NE {GLatLng}, SE {GLatLng}, SW {GLatLng}, NW {GPoint}, NE {GPoint}, SE {GPoint}, SW {GPoint}. The first 4 are the latitudes/longitudes; the last 4 are the pixel coords on the map.
backbuttonclick Function Called after the map context is restored as a result of clicking the DragZoom back button or by calling the initiateZoomBack() method. Callback arg: method (boolean) -- set true if this backbuttonclick was to restore context set by the saveMapContext(text) method, else false.