Adding fractionalZoom property to the map. This allows zooming to an arbitrary level, making it possible to have non-discrete resolutions for layers that support it. This property should not be set to true for layers with fixed zoom levels (commercial layers or others with cached tiles). r=elemoine,crschmidt,ahocevar (closes #1243)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5982 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -176,10 +176,11 @@
|
||||
|
||||
function test_06_Layer_getZoomForResolution(t) {
|
||||
|
||||
t.plan(8);
|
||||
t.plan(12);
|
||||
|
||||
var layer = new OpenLayers.Layer('Test Layer');
|
||||
|
||||
layer.map = {};
|
||||
|
||||
//make some dummy resolutions
|
||||
layer.resolutions = [128, 64, 32, 16, 8, 4, 2];
|
||||
|
||||
@@ -193,6 +194,16 @@
|
||||
|
||||
t.eq(layer.getZoomForResolution(65, true), 1, "closest res");
|
||||
t.eq(layer.getZoomForResolution(63, true), 1, "closest res");
|
||||
|
||||
layer.map.fractionalZoom = true;
|
||||
t.eq(layer.getZoomForResolution(64), 1,
|
||||
"(fractionalZoom) correct zoom for res in array");
|
||||
t.eq(layer.getZoomForResolution(48).toPrecision(6), (1.5).toPrecision(6),
|
||||
"(fractionalZoom) linear scaling for res between entries");
|
||||
t.eq(layer.getZoomForResolution(200).toPrecision(6), (0).toPrecision(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");
|
||||
|
||||
}
|
||||
|
||||
@@ -301,6 +312,41 @@
|
||||
t.ok(layer.imageOffset.equals(desiredImageOffset), "image offset correctly calculated");
|
||||
t.ok(layer.imageSize.equals(desiredImageSize), "image size correctly calculated");
|
||||
}
|
||||
|
||||
function test_Layer_getResolution(t) {
|
||||
t.plan(1);
|
||||
var layer = new OpenLayers.Layer("test");
|
||||
layer.map = {
|
||||
getZoom: function() {return "foo";}
|
||||
};
|
||||
layer.getResolutionForZoom = function(zoom) {
|
||||
t.eq(zoom, "foo", "getResolution calls getResolutionForZoom");
|
||||
}
|
||||
layer.getResolution();
|
||||
layer.map = null;
|
||||
layer.destroy();
|
||||
}
|
||||
|
||||
function test_Layer_getResolutionForZoom(t) {
|
||||
t.plan(5);
|
||||
var layer = new OpenLayers.Layer("test");
|
||||
layer.map = {fractionalZoom: false};
|
||||
layer.resolutions = ["zero", "one", "two"];
|
||||
t.eq(layer.getResolutionForZoom(0), "zero",
|
||||
"(fractionalZoom false) returns resolution for given index");
|
||||
t.eq(layer.getResolutionForZoom(0.9), "one",
|
||||
"(fractionalZoom false) returns resolution for float index");
|
||||
|
||||
layer.resolutions = [2, 4, 6, 8];
|
||||
layer.map.fractionalZoom = true;
|
||||
t.eq(layer.getResolutionForZoom(1).toPrecision(6), (4).toPrecision(6),
|
||||
"(fractionalZoom true) returns resolution for integer zoom");
|
||||
t.eq(layer.getResolutionForZoom(1.5).toPrecision(6), (5).toPrecision(6),
|
||||
"(fractionalZoom true) returns resolution for float zoom");
|
||||
t.eq(layer.getResolutionForZoom(3.5).toPrecision(6), (8).toPrecision(6),
|
||||
"(fractionalZoom true) returns resolution for zoom beyond res length - 1");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user