fix off-by-one error in getZoomForResolution(). Created test to prevent this from happenning again.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1511 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -393,7 +393,7 @@ OpenLayers.Layer.prototype = {
|
|||||||
*/
|
*/
|
||||||
getZoomForResolution: function(resolution) {
|
getZoomForResolution: function(resolution) {
|
||||||
|
|
||||||
for(var i=1; i <= this.resolutions.length; i++) {
|
for(var i=1; i < this.resolutions.length; i++) {
|
||||||
if ( this.resolutions[i] < resolution) {
|
if ( this.resolutions[i] < resolution) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_06_Layer_getZoomForResolution(t) {
|
||||||
|
|
||||||
|
t.plan(4);
|
||||||
|
|
||||||
|
var layer = new OpenLayers.Layer('Test Layer');
|
||||||
|
|
||||||
|
//make some dummy resolutions
|
||||||
|
layer.resolutions = [128, 64, 32, 16, 8, 4, 2];
|
||||||
|
|
||||||
|
t.eq(layer.getZoomForResolution(200), 0, "zoom all the way out");
|
||||||
|
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");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******
|
/******
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user