Add buttons to the PanZoom control which currently allow you to zoom to any level. Add a 'zoomTo' function that

allows you to specify a level. This will need to be refactored: Possibly the zoom control will become part of a 
subclass of PanZoom, "largePanZoom", which has a smaller set of controls.

Also add a DEFAULT_ZOOM_LEVELS setting, and an accesssor for said setting.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@23 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-05-13 01:29:19 +00:00
parent 8bb245832c
commit bc8197969d
2 changed files with 28 additions and 2 deletions

View File

@@ -31,8 +31,12 @@ OpenLayers.Control.PanZoom.prototype =
this._addButton("panright", "east-mini.png", xy.addX(sz.w), sz);
this._addButton("pandown", "south-mini.png", centered.addY(sz.h*2), sz);
this._addButton("zoomin", "zoom-plus-mini.png", centered.addY(sz.h*3), sz);
this._addButton("zoomextents", "zoom-world-mini.png", centered.addY(sz.h*4), sz);
this._addButton("zoomout", "zoom-minus-mini.png", centered.addY(sz.h*5), sz);
centered = centered.addY(sz.h*3);
for (var i=this.map.getZoomLevels(); i--; i>=0) {
centered = centered.addY(sz.h);
this._addButton("zoomLevel"+i, "zoom-world-mini.png", centered, sz);
}
this._addButton("zoomout", "zoom-minus-mini.png", centered.addY(sz.h), sz);
return this.div;
},
@@ -61,7 +65,13 @@ OpenLayers.Control.PanZoom.prototype =
},
buttonDown: function (evt) {
if (this.action.startsWith("zoomLevel")) {
this.map.zoomTo(parseInt(this.action.substr(9,this.action.length)));
}
switch (this.action) {
case "zoomLevel0":
this.map.zoomExtent();
break;
case "panup":
var resolution = this.map.getResolution();
var center = this.map.getCenter();