Merge pull request #4198 from denilsonsa/patch-2

Improve ol.control.Rotate.prototype.resetNorth_ performance
This commit is contained in:
Andreas Hocevar
2015-09-30 16:26:09 +02:00

View File

@@ -119,14 +119,15 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
return;
}
var currentRotation = view.getRotation();
while (currentRotation < -Math.PI) {
currentRotation += 2 * Math.PI;
}
while (currentRotation > Math.PI) {
currentRotation -= 2 * Math.PI;
}
if (currentRotation !== undefined) {
if (this.duration_ > 0) {
currentRotation = currentRotation % (2 * Math.PI);
if (currentRotation < -Math.PI) {
currentRotation += 2 * Math.PI;
}
if (currentRotation > Math.PI) {
currentRotation -= 2 * Math.PI;
}
map.beforeRender(ol.animation.rotate({
rotation: currentRotation,
duration: this.duration_,