Respect zoom level restriction.

This commit is contained in:
ahocevar
2012-06-12 22:57:15 +02:00
parent 3a5abf552a
commit 1d680df6d0

View File

@@ -99,6 +99,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
this.map.events.un({ this.map.events.un({
"changebaselayer": this.redraw, "changebaselayer": this.redraw,
"resize": this.redraw,
scope: this scope: this
}); });
@@ -116,7 +117,11 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
*/ */
setMap: function(map) { setMap: function(map) {
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments); OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
this.map.events.register("changebaselayer", this, this.redraw); this.map.events.on({
"changebaselayer": this.redraw,
"resize": this.redraw,
scope: this
});
}, },
/** /**
@@ -189,6 +194,10 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
_addZoomBar:function(centered) { _addZoomBar:function(centered) {
var imgLocation = OpenLayers.Util.getImageLocation("slider.png"); var imgLocation = OpenLayers.Util.getImageLocation("slider.png");
var id = this.id + "_" + this.map.id; var id = this.id + "_" + this.map.id;
var minZoom = 0;
if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {
minZoom = this.map.adjustZoom(0);
}
var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom(); var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();
var slider = OpenLayers.Util.createAlphaImageDiv(id, var slider = OpenLayers.Util.createAlphaImageDiv(id,
centered.add(-1, zoomsToEnd * this.zoomStopHeight), centered.add(-1, zoomsToEnd * this.zoomStopHeight),
@@ -211,7 +220,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
var sz = { var sz = {
w: this.zoomStopWidth, w: this.zoomStopWidth,
h: this.zoomStopHeight * this.map.getNumZoomLevels() h: this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom)
}; };
var imgLocation = OpenLayers.Util.getImageLocation("zoombar.png"); var imgLocation = OpenLayers.Util.getImageLocation("zoombar.png");
var div = null; var div = null;
@@ -242,7 +251,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
this.map.events.register("zoomend", this, this.moveZoomBar); this.map.events.register("zoomend", this, this.moveZoomBar);
centered = centered.add(0, centered = centered.add(0,
this.zoomStopHeight * this.map.getNumZoomLevels()); this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom));
return centered; return centered;
}, },