Interactive interface for browsing global, full-resolution satellite imagery
Added support for rotation on permalinks, did not work for mouse/swipe rotation yet
Edmond Lee2b1971080a43
diff --git a/web/js/image/wv.image.rubberband.js b/web/js/image/wv.image.rubberband.jsindex a5b058b4d..bfc9d3ba5 100644--- a/web/js/image/wv.image.rubberband.js+++ b/web/js/image/wv.image.rubberband.js@@ -149,6 +149,8 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {rotation: ui.map.selected.getView().getRotation()}));ui.map.selected.getView().rotate(0);+ models.map.rotation = 0.0; //update url to reflect rotation reset+ window.history.replaceState("", "@OFFICIAL_NAME@","?" + models.link.toQueryString());//Let rotation finish before image download can occursetTimeout(toggle, 500);}diff --git a/web/js/link/wv.link.model.js b/web/js/link/wv.link.model.jsindex bd5cf70f1..a871e2420 100644--- a/web/js/link/wv.link.model.js+++ b/web/js/link/wv.link.model.js@@ -43,6 +43,7 @@ wv.link.model = wv.link.model || function(config) {return self;};+ //Returns a serialized string containing information of the current sessionself.toQueryString = function() {var state = {};_.each(components, function(component) {diff --git a/web/js/link/wv.link.ui.js b/web/js/link/wv.link.ui.jsindex 9947e4366..f7ad182d1 100644--- a/web/js/link/wv.link.ui.js+++ b/web/js/link/wv.link.ui.js@@ -48,6 +48,7 @@ wv.link.ui = wv.link.ui || function(models, config) {models.link.events.on("update", replaceHistoryState);};+ //Calls toQueryString to fetch updated state and returns URLvar replaceHistoryState = _.throttle(function() {if ( wv.util.browser.history ) {window.history.replaceState("", "@OFFICIAL_NAME@",diff --git a/web/js/map/wv.map.model.js b/web/js/map/wv.map.model.jsindex 1c528e38e..882c5d527 100644--- a/web/js/map/wv.map.model.js+++ b/web/js/map/wv.map.model.js@@ -19,6 +19,7 @@ wv.map.model = wv.map.model || function(models, config) {var self = {};self.extent = null;+ self.rotation = 0; //initial rotation from urlself.events = wv.util.events();self.update = function(extent) {@@ -26,6 +27,7 @@ wv.map.model = wv.map.model || function(models, config) {self.events.trigger("update", extent);};+ //Set map view from parsed URLself.load = function(state, errors) {if ( state.v ) {var proj = models.proj.selected;@@ -37,11 +39,20 @@ wv.map.model = wv.map.model || function(models, config) {self.extent = _.clone(proj.maxExtent);errors.push({message: "Extent outside of range"});}+ //get rotation if it exists+ if(state.p === 'arctic' || state.p === 'antarctic') {+ if (state.r) //convert to radians here+ self.rotation = state.r * (Math.PI / 180.0);+ } else+ self.rotation = 0; //don't rotate geographic view}};+ //When models.link.toQueryString() is called, save extent and rotationself.save = function(state) {state.v = _.clone(self.extent);+ if(self.rotation !== 0.0 && self.rotation !== 0 && models.proj.selected.id !== 'geographic')+ state.r = self.rotation * (180.0 / Math.PI); //convert from radians to degrees};self.getLeadingExtent = function() {diff --git a/web/js/map/wv.map.ui.js b/web/js/map/wv.map.ui.jsindex 9e93972da..e0c80f674 100644--- a/web/js/map/wv.map.ui.js+++ b/web/js/map/wv.map.ui.js@@ -433,6 +433,7 @@ wv.map.ui = wv.map.ui || function(models, config) {projection: ol.proj.get(proj.crs),extent: proj.maxExtent,center: proj.startCenter,+ rotation: models.map.rotation,zoom: proj.startZoom,maxZoom: proj.numZoomLevels,enableRotation: true@@ -506,6 +507,9 @@ wv.map.ui = wv.map.ui || function(models, config) {rotation: map.getView().getRotation()}));map.getView().rotate(0);+ models.map.rotation = 0.0; //update url to reflect rotation reset+ window.history.replaceState("", "@OFFICIAL_NAME@","?" + models.link.toQueryString());+});};@@ -694,6 +698,8 @@ wv.map.ui = wv.map.ui || function(models, config) {}));map.getView().rotate(map.getView().getRotation() - (Math.PI / amount));+ models.map.rotation = map.getView().getRotation(); //save rotation for permalink+ window.history.replaceState("", "@OFFICIAL_NAME@","?" + models.link.toQueryString());};};