New behavior for layer.getZoomForResolution. This method now returns the index of the resolution closest to the passed in resolution - making for fewer unwanted resolution changes, and a generally happier populace (see #990).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4381 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-09-19 00:23:26 +00:00
parent a2fabd7d17
commit 1f745b4be9
8 changed files with 112 additions and 39 deletions

View File

@@ -155,7 +155,7 @@
function test_06_Layer_getZoomForResolution(t) {
t.plan(4);
t.plan(6);
var layer = new OpenLayers.Layer('Test Layer');
@@ -163,6 +163,8 @@
layer.resolutions = [128, 64, 32, 16, 8, 4, 2];
t.eq(layer.getZoomForResolution(200), 0, "zoom all the way out");
t.eq(layer.getZoomForResolution(65), 1, "index closest to 65");
t.eq(layer.getZoomForResolution(63), 1, "index closest to 63");
t.eq(layer.getZoomForResolution(25), 2, "zoom in middle");
t.eq(layer.getZoomForResolution(3), 5, "zoom allmost all the way in");
t.eq(layer.getZoomForResolution(1), 6, "zoom all the way in");