Changeset 281
- Timestamp:
- 05/23/06 11:39:07 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js
r277 r281 9 9 OpenLayers.Control.PanZoomBar.prototype = 10 10 Object.extend( new OpenLayers.Control.PanZoom(), { 11 / / Array(...)11 /** @type Array(...) */ 12 12 buttons: null, 13 14 /** @type int */ 15 zoomStopWidth: 18, 16 17 /** @type int */ 18 zoomStopHeight: 11, 13 19 14 20 initialize: function() { … … 23 29 draw: function(px) { 24 30 // initialize our internal div 25 OpenLayers.Control.prototype.draw.apply(this );26 this.map.events.register("zoomend", this, this.moveZoomBar);31 OpenLayers.Control.prototype.draw.apply(this, arguments); 32 px = this.position; 27 33 28 34 // place the controls … … 44 50 }, 45 51 _addZoomBar:function(centered,sz) { 46 var zoomStopSize = 15; 52 /*** THIS METHOD IS A HAIRBALL AND SHOULD BE REFACTORED ***/ 53 var zoomStopSize = this.zoomStopHeight; 47 54 var slider = OpenLayers.Util.createImage("img/slider.png", 48 new OpenLayers.Pixel(2 2,9),49 centered.add( 0, (this.map.getZoomLevels())*zoomStopSize), "absolute",55 new OpenLayers.Pixel(20,9), 56 centered.add(-1, (this.map.getZoomLevels())*zoomStopSize), "absolute", 50 57 "OpenLayers_Control_PanZoomBar_Slider"); 51 58 sz.h = zoomStopSize*(this.map.getZoomLevels()+1); 52 sz.w = 17; 59 sz.w = this.zoomStopWidth; 60 53 61 var div = OpenLayers.Util.createDiv('OpenLayers_Control_PanZoomBar_Zoombar',centered,sz); 54 62 div.style.backgroundImage = "url(img/zoombar.png)"; 55 div.onmousedown = this.divClick.bindAsEventListener(div); 56 div.onmousemove = this.zoomBarDivDrag.bindAsEventListener(div); 63 div.onmousedown = this.divClick.bindAsEventListener(div); 57 64 div.ondblclick = this.doubleClick.bindAsEventListener(div); 58 65 div.slider = slider; … … 61 68 div.div = this.div; 62 69 this.div.appendChild(div); 63 slider.startTop = div.style.top; 70 71 slider.startTop = parseInt(div.style.top); 64 72 slider.getMousePosition = this.getMousePosition; 65 73 slider.onmousedown = this.zoomBarDown.bindAsEventListener(slider); … … 69 77 slider.div = this.div; 70 78 slider.map = this.map; 79 slider.zoomStopHeight = this.zoomStopHeight; 71 80 slider.moveZoomBar = this.moveZoomBar; 72 81 slider.zIndex = this.div.zIndex + 5; 73 82 this.div.appendChild(slider); 74 83 this.buttons.append(slider); 84 85 this.map.events.register("zoomend", slider, this.moveZoomBar); 86 75 87 centered = centered.add(0, zoomStopSize*(this.map.getZoomLevels()+1)); 76 88 return centered; … … 80 92 var y = evt.xy.y; 81 93 var top = this.style.top; 82 var levels = Math.floor((y - parseInt(top))/ 15);94 var levels = Math.floor((y - parseInt(top))/this.zoomStopHeight); 83 95 this.map.zoomTo(this.map.getZoomLevels() - levels); 84 96 Event.stop(evt); … … 111 123 evt.xy = this.getMousePosition(evt); 112 124 var deltaY = this.zoomStart.y - evt.xy.y 113 this.map.zoomTo(this.map.zoom + Math.round(deltaY/ 15));125 this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight)); 114 126 this.moveZoomBar(); 115 127 this.div.style.cursor="default"; … … 118 130 }, 119 131 moveZoomBar:function() { 120 var slider = $('OpenLayers_Control_PanZoomBar_Slider'); 121 slider.style.top = (this.map.getZoomLevels() - this.map.getZoom())*15+ 122 parseInt(document.getElementById("OpenLayers_Control_PanZoomBar_Zoombar").style.top) + 3; 132 /*** `this` is actually slider... that should be fixed at some point */ 133 var newTop = 134 (this.map.getZoomLevels() - this.map.getZoom()) * this.zoomStopHeight 135 + this.startTop + 1; 136 this.style.top = newTop + "px"; 123 137 }, 124 138
