Interactive interface for browsing global, full-resolution satellite imagery
Added this.saveRotation reusable method. - Combine redundant functionality in this.rotate and this.updateRotation into one reusable method called this.saveRotation.
ZachTRiceb72ede8fd654
diff --git a/web/js/map/wv.map.rotate.js b/web/js/map/wv.map.rotate.jsindex 5ee931d20..4e2eda906 100644--- a/web/js/map/wv.map.rotate.js+++ b/web/js/map/wv.map.rotate.js@@ -135,6 +135,28 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {});};+ /**+ * Saves the rotation degrees as a number within -360 & 360 degrees+ *+ * @param {type} currentDeg The current rotation degrees+ * @param {type} currentView The current rotation view+ * @return {type} Compare the current degrees to 360 degrees minus the new view's degree value.+ * This ensures the maximum degrees never exceeds +/- 360.+ * The current view is then set to this new value.+ */+ this.saveRotation = function(currentDeg, currentView) {+ if (Math.abs(currentDeg) === 360) {+ currentView.setRotation(0);+ } else if (Math.abs(currentDeg) >= 360) {+ var newNadVal = ((360 - Math.abs(currentDeg)) * (Math.PI / 180));+ if (currentDeg < 0) {+ currentView.setRotation(newNadVal);+ } else {+ currentView.setRotation(-newNadVal);+ }+ }+ };+/** Called as event listener when map is rotated. Update url to reflect rotation reset*@@ -146,25 +168,16 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {this.updateRotation = function() {var deg,radians,- view,+ currentView,currentDeg;- view = ui.selected.getView();- radians = view.getRotation();+ currentView = ui.selected.getView();+ radians = currentView.getRotation();models.map.rotation = radians;self.setResetButton(radians);- currentDeg = (view.getRotation() * (180.0 / Math.PI));- if (Math.abs(currentDeg) === 360) {- view.setRotation(0);- } else if (Math.abs(currentDeg) >= 360) {- var newNadVal = ((360 - Math.abs(currentDeg)) * (Math.PI / 180));- if (currentDeg < 0) {- view.setRotation(newNadVal);- } else {- view.setRotation(-newNadVal);- }- }+ currentDeg = (currentView.getRotation() * (180.0 / Math.PI));+ this.saveRotation(currentDeg, currentView);};/*@@ -222,19 +235,9 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {var currentDeg = (map.getView().getRotation() * (180.0 / Math.PI));- if (Math.abs(currentDeg) === 360) {- map.getView()- .setRotation(0);- } else if (Math.abs(currentDeg) >= 360) {- var newNadVal = ((360 - Math.abs(currentDeg)) * (Math.PI / 180));- if (currentDeg < 0) {- map.getView()- .setRotation(newNadVal);- } else {- map.getView()- .setRotation(-newNadVal);- }- }++ this.saveRotation(currentDeg, currentView);+map.getView().animate({rotation: map.getView()