diff --git a/lib/OpenLayers/Control/PanZoom.js b/lib/OpenLayers/Control/PanZoom.js index b94d15d76f..ea9f2c38ff 100644 --- a/lib/OpenLayers/Control/PanZoom.js +++ b/lib/OpenLayers/Control/PanZoom.js @@ -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(); diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 2f6a44d377..9816f14b4b 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -7,6 +7,9 @@ OpenLayers.Map = Class.create(); OpenLayers.Map.prototype = { + // int zoom levels, used to draw zoom dragging control + DEFAULT_ZOOM_LEVELS: 16, + // OpenLayers.Bounds DEFAULT_FULL_EXTENT: new OpenLayers.Bounds(-90, -180, 90, 180), @@ -170,6 +173,10 @@ OpenLayers.Map.prototype = { getFullExtent: function () { return this.DEFAULT_FULL_EXTENT; }, + + getZoomLevels: function() { + return this.DEFAULT_ZOOM_LEVELS; + }, /** * @param {OpenLayers.Bounds} bounds @@ -244,6 +251,15 @@ OpenLayers.Map.prototype = { }, + /** + * zoomTo + * Set Zoom To int + */ + zoomTo: function(zoom) { + this.zoom = zoom; + this.moveToNewExtent(true); + }, + /** * zoomOut * Decrease zoom level by one.