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
+17 -3
View File
@@ -78,13 +78,27 @@
bounds = new OpenLayers.Bounds(10,10,12,12);
zoom = layer.getZoomForExtent(bounds);
t.eq( zoom, 7, "getZoomForExtent() returns correct value");
/**
* ideal resolution: 2 map units / 500px = 0.004
* layer.resolutions = [0.703125, 0.3515625, 0.17578125,
* 0.087890625, 0.0439453125, 0.02197265625,
* 0.010986328125, 0.0054931640625, 0.00274658203125,
* 0.001373291015625, 0.0006866455078125, 0.00034332275390625,
* 0.000171661376953125, 0.0000858306884765625, 0.00004291534423828125,
* 0.000021457672119140625]
*
* So, we expect a zoom of 8 because it is the closest resolution.
*/
t.eq( zoom, 8, "getZoomForExtent() returns correct value");
bounds = new OpenLayers.Bounds(10,10,100,100);
zoom = layer.getZoomForExtent(bounds);
/**
* ideal resolution: 90 map units / 500px = 0.18
* So, we expect a zoom of 2 because it is the closest.
*/
t.eq( zoom, 1, "getZoomForExtent() returns correct value");
t.eq( zoom, 2, "getZoomForExtent() returns correct value");
}