Snap center to pixel to avoid floating point issues

This commit is contained in:
Andreas Hocevar
2015-07-28 14:02:09 +02:00
parent 5e4474ca8c
commit 5e505f200a
2 changed files with 5 additions and 1 deletions

View File

@@ -400,7 +400,11 @@ ol.View.prototype.getState = function() {
var resolution = /** @type {number} */ (this.getResolution());
var rotation = this.getRotation();
return /** @type {olx.ViewState} */ ({
center: center.slice(),
// Snap center to closest pixel
center: [
Math.round(center[0] / resolution) * resolution,
Math.round(center[1] / resolution) * resolution
],
projection: goog.isDef(projection) ? projection : null,
resolution: resolution,
rotation: rotation