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
This commit is contained in:
@@ -47,10 +47,13 @@ OpenLayers.Control.PanZoomBar.prototype =
|
|||||||
sz.w = 17;
|
sz.w = 17;
|
||||||
var div = OpenLayers.Util.createDiv('OpenLayers_Control_PanZoomBar_Zoombar',centered,sz);
|
var div = OpenLayers.Util.createDiv('OpenLayers_Control_PanZoomBar_Zoombar',centered,sz);
|
||||||
div.style.backgroundImage = "url(img/zoombar.png)";
|
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.onmousemove = this.zoomBarDivDrag.bindAsEventListener(div);
|
||||||
div.ondblclick = this.doubleClick.bindAsEventListener(div);
|
div.ondblclick = this.doubleClick.bindAsEventListener(div);
|
||||||
div.slider = slider;
|
div.slider = slider;
|
||||||
|
div.getMousePosition = this.getMousePosition;
|
||||||
|
div.map = this.map;
|
||||||
|
div.div = this.div;
|
||||||
this.div.appendChild(div);
|
this.div.appendChild(div);
|
||||||
slider.startTop = div.style.top;
|
slider.startTop = div.style.top;
|
||||||
slider.getMousePosition = this.getMousePosition;
|
slider.getMousePosition = this.getMousePosition;
|
||||||
@@ -67,6 +70,14 @@ OpenLayers.Control.PanZoomBar.prototype =
|
|||||||
centered = centered.add(0, zoomStopSize*(this.map.getZoomLevels()+1));
|
centered = centered.add(0, zoomStopSize*(this.map.getZoomLevels()+1));
|
||||||
return centered;
|
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) {
|
getMousePosition: function (evt) {
|
||||||
var offsets = Position.page(this.div);
|
var offsets = Position.page(this.div);
|
||||||
return new OpenLayers.Pixel(
|
return new OpenLayers.Pixel(
|
||||||
|
|||||||
Reference in New Issue
Block a user