git-svn-id: http://svn.openlayers.org/trunk/openlayers@3787 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
|
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
|
* for the full text of the license. */
|
|
|
|
/**
|
|
* @requires OpenLayers/Control.js
|
|
* @requires OpenLayers/Handler/Box.js
|
|
*
|
|
* Class: OpenLayers.Control.ZoomBox
|
|
*
|
|
* Inherits from:
|
|
* - <OpenLayers.Control>
|
|
*/
|
|
OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
|
|
/**
|
|
* Property: type
|
|
* {OpenLayers.Control.TYPE}
|
|
*/
|
|
type: OpenLayers.Control.TYPE_TOOL,
|
|
|
|
/**
|
|
* Method: draw
|
|
*/
|
|
draw: function() {
|
|
this.handler = new OpenLayers.Handler.Box( this,
|
|
{done: this.zoomBox}, {keyMask: this.keyMask} );
|
|
},
|
|
|
|
/**
|
|
* Method: zoomBox
|
|
*
|
|
* Parameters:
|
|
* position - {<OpenLayers.Bounds>} or {<OpenLayers.Pixel>}
|
|
*/
|
|
zoomBox: function (position) {
|
|
if (position instanceof OpenLayers.Bounds) {
|
|
var minXY = this.map.getLonLatFromPixel(
|
|
new OpenLayers.Pixel(position.left, position.bottom));
|
|
var maxXY = this.map.getLonLatFromPixel(
|
|
new OpenLayers.Pixel(position.right, position.top));
|
|
var bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
|
|
maxXY.lon, maxXY.lat);
|
|
this.map.zoomToExtent(bounds);
|
|
} else { // it's a pixel
|
|
this.map.setCenter(this.map.getLonLatFromPixel(position),
|
|
this.map.getZoom() + 1);
|
|
}
|
|
},
|
|
|
|
CLASS_NAME: "OpenLayers.Control.ZoomBox"
|
|
});
|