Change to getZoomForResolution() (and those who call it) so that it does not choose the closest fit by default. Doing so was causing us problems, because user would drag a zoom box and then the map's new zoom would not contain said zoombox. Not good. Default is back to how it was before, but now there's an option 'closest' for those times when what we really want is the closest. Right now, the only time that's true is when we're switching baselayers. This is based on the work from sandbox/euzuro/zoomToResolution, which is started by reverting r4318. (Closes #1043)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4792 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-10-03 19:21:05 +00:00
parent cb494d0c3f
commit 137a69b17a
9 changed files with 86 additions and 122 deletions

View File

@@ -158,7 +158,7 @@
function test_06_Layer_getZoomForResolution(t) {
t.plan(6);
t.plan(8);
var layer = new OpenLayers.Layer('Test Layer');
@@ -166,12 +166,16 @@
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");
t.eq(layer.getZoomForResolution(65), 0, "smallest containing res");
t.eq(layer.getZoomForResolution(63), 1, "smallest containing res");
t.eq(layer.getZoomForResolution(65, true), 1, "closest res");
t.eq(layer.getZoomForResolution(63, true), 1, "closest res");
}
function test_07_Layer_redraw(t) {