Snap view center to pixel

This commit is contained in:
Andreas Hocevar
2017-11-29 14:52:05 +01:00
parent 45d2f8debb
commit 3bb62a2c41
14 changed files with 5 additions and 1 deletions

View File

@@ -1139,11 +1139,15 @@ ol.PluggableMap.prototype.renderFrame_ = function(time) {
layerStates[ol.getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
}
viewState = view.getState();
var center = viewState.center;
var pixelResolution = viewState.resolution / this.pixelRatio_;
center[0] = Math.round(center[0] / pixelResolution) * pixelResolution;
center[1] = Math.round(center[1] / pixelResolution) * pixelResolution;
frameState = /** @type {olx.FrameState} */ ({
animate: false,
coordinateToPixelTransform: this.coordinateToPixelTransform_,
extent: extent,
focus: !this.focus_ ? viewState.center : this.focus_,
focus: !this.focus_ ? center : this.focus_,
index: this.frameIndex_++,
layerStates: layerStates,
layerStatesArray: layerStatesArray,