Support fractional zoom levels in ol.View#getZoom and #setZoom
This commit is contained in:
@@ -21,7 +21,13 @@ ol.ResolutionConstraint.createSnapToResolutions = function(resolutions) {
|
||||
var z =
|
||||
ol.array.linearFindNearest(resolutions, resolution, direction);
|
||||
z = ol.math.clamp(z + delta, 0, resolutions.length - 1);
|
||||
return resolutions[z];
|
||||
var index = Math.floor(z);
|
||||
if (z != index && index < resolutions.length - 1) {
|
||||
var power = resolutions[index] / resolutions[index + 1];
|
||||
return resolutions[index] / Math.pow(power, z - index);
|
||||
} else {
|
||||
return resolutions[index];
|
||||
}
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
@@ -45,14 +51,7 @@ ol.ResolutionConstraint.createSnapToPower = function(power, maxResolution, opt_m
|
||||
*/
|
||||
function(resolution, delta, direction) {
|
||||
if (resolution !== undefined) {
|
||||
var offset;
|
||||
if (direction > 0) {
|
||||
offset = 0;
|
||||
} else if (direction < 0) {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = 0.5;
|
||||
}
|
||||
var offset = -direction / 2 + 0.5;
|
||||
var oldLevel = Math.floor(
|
||||
Math.log(maxResolution / resolution) / Math.log(power) + offset);
|
||||
var newLevel = Math.max(oldLevel + delta, 0);
|
||||
|
||||
Reference in New Issue
Block a user