From 90460002cb22d796c489e98e4783190a30e7afa2 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 17 May 2006 02:48:18 +0000 Subject: [PATCH] Register 'zoomend' event. Use zoomend event registration to move zoomer when zoom level changes. And it even works right. git-svn-id: http://svn.openlayers.org/trunk/openlayers@78 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/PanZoomBar.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index 11298375e6..fc47c59f23 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -15,6 +15,7 @@ OpenLayers.Control.PanZoomBar.prototype = }, draw: function() { + this.map.events.register("zoomend", this, this.moveZoomBar); // initialize our internal div OpenLayers.Control.prototype.draw.apply(this); @@ -59,6 +60,7 @@ OpenLayers.Control.PanZoomBar.prototype = slider.ondblclick = this.doubleClick.bindAsEventListener(slider); slider.div = this.div; slider.map = this.map; + slider.moveZoomBar = this.moveZoomBar; slider.zIndex = this.div.zIndex + 5; this.div.appendChild(slider); this.buttons.append(slider); @@ -93,12 +95,16 @@ OpenLayers.Control.PanZoomBar.prototype = evt.xy = this.getMousePosition(evt); var deltaY = this.zoomStart.y - evt.xy.y this.map.zoomTo(this.map.zoom + Math.round(deltaY/15)); - this.style.top = (this.map.getZoomLevels() - this.map.getZoom())*15+ - parseInt(document.getElementById("OpenLayers_Control_PanZoomBar_Zoombar").style.top) + 3; + this.moveZoomBar(); this.div.style.cursor="default"; this.mouseDragStart = null; Event.stop(evt); }, + moveZoomBar:function() { + var slider = $('OpenLayers_Control_PanZoomBar_Slider'); + slider.style.top = (this.map.getZoomLevels() - this.map.getZoom())*15+ + parseInt(document.getElementById("OpenLayers_Control_PanZoomBar_Zoombar").style.top) + 3; + }, _addButton:function(id, img, xy, sz) { var imgLocation = OpenLayers.Util.getImagesLocation() + img; // var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz);