From ebcebe6ef7f8a1bc4bb99832d1ff82ca05309b00 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 17 May 2006 03:17:55 +0000 Subject: [PATCH] Add code to capture 'clicks' on the zoombar, and deliver the zoom to that level. This matches the Google Maps expectation of being able to click on a 'rung' and zoom in to that level. git-svn-id: http://svn.openlayers.org/trunk/openlayers@82 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/PanZoomBar.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index fc47c59f23..50d506d7f5 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -47,10 +47,13 @@ OpenLayers.Control.PanZoomBar.prototype = sz.w = 17; var div = OpenLayers.Util.createDiv('OpenLayers_Control_PanZoomBar_Zoombar',centered,sz); div.style.backgroundImage = "url(img/zoombar.png)"; - div.onmousedown = this.doubleClick.bindAsEventListener(div); + div.onmousedown = this.divClick.bindAsEventListener(div); div.onmousemove = this.zoomBarDivDrag.bindAsEventListener(div); div.ondblclick = this.doubleClick.bindAsEventListener(div); div.slider = slider; + div.getMousePosition = this.getMousePosition; + div.map = this.map; + div.div = this.div; this.div.appendChild(div); slider.startTop = div.style.top; slider.getMousePosition = this.getMousePosition; @@ -67,6 +70,14 @@ OpenLayers.Control.PanZoomBar.prototype = centered = centered.add(0, zoomStopSize*(this.map.getZoomLevels()+1)); return centered; }, + divClick: function (evt) { + evt.xy = this.getMousePosition(evt); + var y = evt.xy.y; + var top = this.style.top; + var levels = Math.floor((y - parseInt(top))/15); + this.map.zoomTo(this.map.getZoomLevels() - levels); + Event.stop(evt); + }, getMousePosition: function (evt) { var offsets = Position.page(this.div); return new OpenLayers.Pixel(