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

@@ -78,33 +78,38 @@ OpenLayers.Map.prototype = {
// Options
/** @type OpenLayers.Size */
tileSize: null,
/** @type String */
projection: "EPSG:4326",
/** @type OpenLayers.Bounds */
maxExtent: null,
/** @type String */
units: 'degrees',
/** default max is 360 deg / 256 px, which corresponds to
* zoom level 0 on gmaps
*
* @type float */
maxResolution: 1.40625,
/** @type int */
minZoomLevel: 0,
/** @type int */
maxZoomLevel: 16,
/** @type float */
minResolution: null,
/** @type OpenLayers.Size */
tileSize: null,
/** @type float */
maxScale: null,
/** @type String */
units: 'degrees',
/** @type Float */
/** @type float */
minScale: null,
/** @type OpenLayers.Bounds */
maxExtent: null,
/** @type OpenLayers.Bounds */
minExtent: null,
/** @type int */
numZoomLevels: 16,
/**
@@ -207,16 +212,6 @@ OpenLayers.Map.prototype = {
// now add the options declared by the user
// (these will override defaults)
Object.extend(this, options);
// if maxResolution is specified as "auto", calculate it
// based on the maxExtent and the viewSize
//
if (this.maxResolution == "auto" || this.maxResolution == null) {
var maxExtent = this.getMaxExtent();
var viewSize = this.getSize();
this.maxResolution = Math.max(maxExtent.getWidth() / viewSize.w,
maxExtent.getHeight() / viewSize.h );
}
},
/**
@@ -647,8 +642,8 @@ OpenLayers.Map.prototype = {
*/
isValidZoomLevel: function(zoomLevel) {
return ( (zoomLevel != null) &&
(zoomLevel >= this.getMinZoomLevel()) &&
(zoomLevel <= this.getMaxZoomLevel()) );
(zoomLevel >= 0) &&
(zoomLevel < this.getNumZoomLevels()) );
},
/**
@@ -684,15 +679,9 @@ OpenLayers.Map.prototype = {
*/
getProjection: function() {
var projection = null;
if (this.baseLayer != null) {
projection = this.baseLayer.getProjection();
}
if (projection == null) {
projection = this.projection;
}
return projection;
},
@@ -702,15 +691,9 @@ OpenLayers.Map.prototype = {
*/
getMaxResolution: function() {
var maxResolution = null;
if (this.baseLayer != null) {
maxResolution = this.baseLayer.getMaxResolution();
}
if (maxResolution == null) {
maxResolution = this.maxResolution;
}
return maxResolution;
},
@@ -719,55 +702,25 @@ OpenLayers.Map.prototype = {
*/
getMaxExtent: function () {
var maxExtent = null;
if (this.baseLayer != null) {
maxExtent = this.baseLayer.getMaxExtent();
}
if (maxExtent == null) {
maxExtent = this.maxExtent;
}
}
return maxExtent;
},
/**
* @returns The maximum zoom level that can be reached in the map
* @returns The total number of zoom levels that can be displayed by the
* current baseLayer.
* @type int
*/
getMaxZoomLevel: function() {
var maxZoomLevel = null;
getNumZoomLevels: function() {
var numZoomLevels = null;
if (this.baseLayer != null) {
maxZoomLevel = this.baseLayer.getMaxZoomLevel();
numZoomLevels = this.baseLayer.getNumZoomLevels();
}
if (maxZoomLevel == null) {
maxZoomLevel = this.maxZoomLevel;
}
return maxZoomLevel;
return numZoomLevels;
},
/**
* @returns The minimum zoom level that can be reached in the map
* @type int
*/
getMinZoomLevel: function() {
var minZoomLevel = null;
if (this.baseLayer != null) {
minZoomLevel = this.baseLayer.getMinZoomLevel();
}
if (minZoomLevel == null) {
minZoomLevel = this.minZoomLevel;
}
return minZoomLevel;
},
/********************************************************/
/* */
/* Baselayer Functions */
@@ -787,7 +740,6 @@ OpenLayers.Map.prototype = {
*/
getExtent: function () {
var extent = null;
if (this.baseLayer != null) {
extent = this.baseLayer.getExtent();
}
@@ -801,7 +753,6 @@ OpenLayers.Map.prototype = {
*/
getResolution: function () {
var resolution = null;
if (this.baseLayer != null) {
resolution = this.baseLayer.getResolution();
}
@@ -815,7 +766,6 @@ OpenLayers.Map.prototype = {
*/
getScale: function () {
var scale = null;
if (this.baseLayer != null) {
var res = this.getResolution();
var units = this.baseLayer.units;
@@ -835,7 +785,6 @@ OpenLayers.Map.prototype = {
*/
getZoomForExtent: function (bounds) {
zoom = null;
if (this.baseLayer != null) {
zoom = this.baseLayer.getZoomForExtent(bounds);
}