removing the restrictedMinZoom property, and allow for restricting zoom levels with maxResolution and numZoomLevels. Thanks tschaub for the doc, test and examples improvements. r=tschaub (see #3338)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12106 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+14
-7
@@ -82,9 +82,9 @@
|
||||
|
||||
function test_Layer_addOptions (t) {
|
||||
|
||||
t.plan( 19 );
|
||||
t.plan( 20 );
|
||||
|
||||
var map = new OpenLayers.Map("map");
|
||||
var map = new OpenLayers.Map("map", {allOverlays: true});
|
||||
var options = { chicken: 151, foo: "bar" };
|
||||
var layer = new OpenLayers.Layer('Test Layer', options);
|
||||
map.addLayer(layer);
|
||||
@@ -156,6 +156,17 @@
|
||||
layer.addOptions({projection: "EPSG:900913"});
|
||||
t.ok(layer.projection instanceof OpenLayers.Projection,
|
||||
"addOptions creates a Projection object when given a projection string");
|
||||
|
||||
log = null;
|
||||
// adding a 2nd layer to see if it gets reinitialized properly
|
||||
var layer2 = new OpenLayers.Layer(null, {
|
||||
moveTo: function(bounds) {
|
||||
log = bounds;
|
||||
}
|
||||
});
|
||||
map.addLayer(layer2);
|
||||
layer.addOptions({maxResolution: 0.00034332275390625}, true);
|
||||
t.eq(log.toBBOX(), map.getExtent().toBBOX(), "when reinitialize is set to true, changing base layer's resolution property reinitializes all layers.");
|
||||
|
||||
map.removeLayer(layer);
|
||||
log = 0;
|
||||
@@ -556,7 +567,7 @@
|
||||
|
||||
function test_Layer_getZoomForResolution(t) {
|
||||
|
||||
t.plan(13);
|
||||
t.plan(12);
|
||||
|
||||
var layer = new OpenLayers.Layer('Test Layer');
|
||||
layer.map = {};
|
||||
@@ -584,10 +595,6 @@
|
||||
"(fractionalZoom) doesn't return zoom below zero");
|
||||
t.eq(layer.getZoomForResolution(1).toPrecision(6), (layer.resolutions.length - 1).toPrecision(6),
|
||||
"(fractionalZoom) doesn't return zoom above highest index");
|
||||
|
||||
layer.restrictedMinZoom = 1;
|
||||
t.eq(layer.getZoomForResolution(200), 1, "zoom all the way out, but we have a restrictedMinZoom of 1");
|
||||
|
||||
}
|
||||
|
||||
function test_Layer_redraw(t) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
var log = {};
|
||||
layer = new OpenLayers.Layer.GoogleNG({
|
||||
numZoomLevels: 10,
|
||||
restrictedMinZoom: 2,
|
||||
maxResolution: 39135.7584765625,
|
||||
initLayer: function() {
|
||||
log[layer.id] = true;
|
||||
OpenLayers.Layer.GoogleNG.prototype.initLayer.apply(this, arguments);
|
||||
@@ -30,13 +30,14 @@
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
var map2 = new OpenLayers.Map("map2");
|
||||
var minZoom = 1;
|
||||
var layer2 = new OpenLayers.Layer.GoogleNG({
|
||||
numZoomLevels: 24,
|
||||
initLayer: function() {
|
||||
log[layer2.id] = true;
|
||||
var origMinZoom = OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].minZoom;
|
||||
// pretend the API reports a minZoom of 1
|
||||
OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].minZoom = 1;
|
||||
// pretend the API reports a different minZoom
|
||||
OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].minZoom = minZoom;
|
||||
OpenLayers.Layer.GoogleNG.prototype.initLayer.apply(this, arguments);
|
||||
OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].minZoom = origMinZoom;
|
||||
}
|
||||
@@ -49,10 +50,10 @@
|
||||
t.eq(log[layer2.id], true, "initLayer called for 2nd layer");
|
||||
|
||||
t.eq(layer.numZoomLevels, 10, "numZoomLevels from configuration takes precedence if lower");
|
||||
t.eq(layer2.numZoomLevels, OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].maxZoom+1, "numZoomLevels from API takes precedence if lower");
|
||||
t.eq(layer2.numZoomLevels, OpenLayers.Layer.GoogleNG.mapObject.mapTypes[layer2.type].maxZoom + 1 - minZoom, "numZoomLevels from API takes precedence if lower");
|
||||
|
||||
t.eq(layer.restrictedMinZoom, 2, "restrictedMinZoom from configuration takes precedence if higher");
|
||||
t.eq(layer2.restrictedMinZoom, 1, "restrictedMinZoom from API takes precedence if higher");
|
||||
t.eq(layer.maxResolution, 39135.7584765625, "maxResolution from configuration takes precedence if higher");
|
||||
t.eq(layer2.maxResolution, 78271.516953125, "maxResolution from API takes precedence if higher");
|
||||
|
||||
map.destroy();
|
||||
map2.destroy();
|
||||
|
||||
+5
-33
@@ -338,31 +338,24 @@
|
||||
*/
|
||||
|
||||
function test_Map_isValidZoomLevel(t) {
|
||||
t.plan(6);
|
||||
t.plan(4);
|
||||
var map = new OpenLayers.Map("map");
|
||||
map.addLayer(new OpenLayers.Layer(null, {
|
||||
isBaseLayer: true, numZoomLevels: 19
|
||||
}))
|
||||
var valid;
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [-1]);
|
||||
t.eq(valid, false, "-1 is not a valid zoomLevel");
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [0]);
|
||||
t.eq(valid, true, "0 is a valid zoomLevel when baseLayer has no restrictedMinZoom");
|
||||
t.eq(valid, true, "0 is a valid zoomLevel");
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [18]);
|
||||
t.eq(valid, true, "18 is a valid zoomLevel");
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [19]);
|
||||
t.eq(valid, false, "19 is not a valid zoomLevel");
|
||||
|
||||
map.baseLayer.restrictedMinZoom = 1;
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [0]);
|
||||
t.eq(valid, false, "0 is not a valid zoomLevel when baseLayer has restrictedMinZoom of 1");
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [1]);
|
||||
t.eq(valid, true, "1 is a valid zoomLevel");
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [19]);
|
||||
t.eq(valid, false, "19 is not a valid zoomLevel when baseLayer has restrictedMinZoom of 1");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
@@ -1296,27 +1289,6 @@
|
||||
var maxExtent = OpenLayers.Map.prototype.getMaxExtent.apply(map, [options]);
|
||||
t.ok(maxExtent == map.baseLayer.maxExtent, "null options, valid baseLayer returns map.baseLayer.maxExtent");
|
||||
}
|
||||
|
||||
function test_Map_getRestrictedMinZoom(t){
|
||||
t.plan(3);
|
||||
|
||||
var map = {};
|
||||
|
||||
//no baseLayer
|
||||
var minZoom = OpenLayers.Map.prototype.getRestrictedMinZoom.apply(map);
|
||||
t.eq(minZoom, null, "no baseLayer returns null");
|
||||
|
||||
map.baseLayer = new OpenLayers.Layer(null, {isBaseLayer: true});
|
||||
|
||||
//baseLayer
|
||||
minZoom = OpenLayers.Map.prototype.getRestrictedMinZoom.apply(map);
|
||||
t.eq(minZoom, 0, "default baseLayer.restrictedMinZoom returns 0");
|
||||
|
||||
//custom minZoomLevel on baseLayer
|
||||
map.baseLayer.restrictedMinZoom = 1;
|
||||
minZoom = OpenLayers.Map.prototype.getRestrictedMinZoom.apply(map);
|
||||
t.eq(minZoom, map.baseLayer.restrictedMinZoom, "custom baseLayer.restrictedMinZoom returns map.baseLayer.restrictedMinZoom");
|
||||
}
|
||||
|
||||
function test_Map_zoomToMaxExtent(t){
|
||||
t.plan(4)
|
||||
|
||||
Reference in New Issue
Block a user