Remove the concept of min/max zoom level from Map. Replace it with concept of num zoom levels. Bit of rearrangement in the initResolutions() function in HTTPRequest.js. Adapt all of OL to deal with numZoomLevels instead of min/max. Fix PanZoomBar so that it listens for change of baselayer and redraws itself. fix all tests so they pass. Add zoomLevels.html example for playing around with different methods of setting zoomlevels.

git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1302 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-08-19 02:09:29 +00:00
parent 1a12d90455
commit 17581c714d
11 changed files with 205 additions and 160 deletions

View File

@@ -28,9 +28,28 @@ OpenLayers.Control.PanZoomBar.prototype =
// put code here to catch "changebaselayer" event from map, because
// we are going to have to redraw this thing each time, because
// maxZoom will/might change.
// numZoomLevels will/might change.
},
/**
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
this.map.events.register("changebaselayer", this, this.redraw);
},
/** clear the div and start over.
*
*/
redraw: function() {
if (this.div != null) {
this.div.innerHTML = "";
}
this.draw();
},
/**
* @param {OpenLayers.Pixel} px
*/
@@ -65,7 +84,7 @@ OpenLayers.Control.PanZoomBar.prototype =
var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id;
var slider = OpenLayers.Util.createAlphaImageDiv(id,
centered.add(-1,
(this.map.getMaxZoomLevel())*this.zoomStopHeight),
(this.map.getNumZoomLevels()-1) * this.zoomStopHeight),
new OpenLayers.Size(20,9),
imgLocation+"slider.png",
"absolute");
@@ -79,7 +98,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.sliderEvents.register("click", this, this.doubleClick);
sz = new OpenLayers.Size();
sz.h = this.zoomStopHeight*(this.map.getMaxZoomLevel()+1);
sz.h = this.zoomStopHeight * this.map.getNumZoomLevels();
sz.w = this.zoomStopWidth;
var div = null
@@ -115,7 +134,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.map.events.register("zoomend", this, this.moveZoomBar);
centered = centered.add(0,
this.zoomStopHeight*(this.map.getMaxZoomLevel()+1));
this.zoomStopHeight * this.map.getNumZoomLevels());
return centered;
},
/*
@@ -136,7 +155,7 @@ OpenLayers.Control.PanZoomBar.prototype =
var y = evt.xy.y;
var top = Position.page(evt.object)[1];
var levels = Math.floor((y - top)/this.zoomStopHeight);
this.map.zoomTo(this.map.getMaxZoomLevel() - levels);
this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
Event.stop(evt);
},
@@ -198,8 +217,8 @@ OpenLayers.Control.PanZoomBar.prototype =
*/
moveZoomBar:function() {
var newTop =
(this.map.getMaxZoomLevel() - this.map.getZoom()) * this.zoomStopHeight
+ this.startTop + 1;
((this.map.getNumZoomLevels()-1) - this.map.getZoom()) *
this.zoomStopHeight + this.startTop + 1;
this.slider.style.top = newTop + "px";
},