zoombox.js
来自「用来在地图上做操作GIS,在地图上做标记」· JavaScript 代码 · 共 52 行
JS
52 行
/* Copyright (c) 2006-2007 MetaCarta, Inc., published under the BSD license. * See http://svn.openlayers.org/trunk/openlayers/release-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"});
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?