DragZoomControl

This library lets you add a control to the map which will let the user zoom by dragging a rectangle. Back Button functionality provides the user with a one click means to return the map state to its state prior to the DragZoom. Sequential DragZooms are backed out in reverse order.

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. This class extends GControl.

Constructor

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

Methods

Methods Return Value Description
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.
saveMapContext(text) None Method called to save the map context before the zoom. The map state is pushed onto the context stack, the backButtonHTML is set to 'text', and the back button is made visible.

Events

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

class DragZoomControlBoxStyleOptions

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

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

class DragZoomControlCallbackOptions

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

Properties Type Description
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 args are: method {Boolean} -- set true if this backbuttonclick was to restore context set by the saveMapContext(text) method, else false.
buttonclick Function Called when DragZoom is activated by clicking on the DragZoom button or by calling the buttonclick() method.
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.
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.
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.

class DragZoomControlOtherOptions

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

Properties Type Description
backButtonEnabled Boolean Determines whether or not the back button functionality is turned on. The default value is false.
backButtonHTML String HTML which is placed in the back button when the button is activated.
backButtonStyle Object A hash of CSS styles for the back button which will be applied when the button is activated. The default value is {background: '#FFF', display: 'none'}.
buttonHTML String The zoom button HTML in non-activated state. The default value is "zoom ...".
buttonStartingStyle Object A hash of css styles for the zoom button which are common to both un-activated and activated state. The default value 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. The default value is {background: '#FFF'}.
buttonZoomingHTML String HTML which is placed in the zoom button when the button is activated. The default value 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. The default value is {background: '#FF0'}.
minDragSize Number Often, users will try to "cancel" a dragzoom operation by resizing their selected rectangle to a point. This specifies a minimum size in pixels for the dragged rectangle to trigger a zoom. Something like 3-5 is sensible for most cases. The default value is 0.
overlayRemoveTime Number The number of milliseconds to wait before removing the rectangle indicating the zoomed-in area after the zoom has happened. The default value is 6000.
rightMouseZoomOutEnabled Boolean Whether to zoom out when a drag with the right mouse button occurs. The default value is false.
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. The default value is false.