Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

URL now updated upon any rotation

Edmond Leeefb719b0f65a
diff --git a/web/js/image/wv.image.rubberband.js b/web/js/image/wv.image.rubberband.js
index bfc9d3ba5..0c5824b15 100644
--- a/web/js/image/wv.image.rubberband.js
+++ b/web/js/image/wv.image.rubberband.js
@@ -149,8 +149,7 @@ 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());
+ ui.map.updateRotation();
//Let rotation finish before image download can occur
setTimeout(toggle, 500);
}
diff --git a/web/js/map/wv.map.ui.js b/web/js/map/wv.map.ui.js
index 21a3a5035..b750d1638 100644
--- a/web/js/map/wv.map.ui.js
+++ b/web/js/map/wv.map.ui.js
@@ -394,12 +394,19 @@ wv.map.ui = wv.map.ui || function(models, config) {
self.events.trigger("extent");
}, 500, { trailing: true });
+ //Called as event listener when map is zoomed or panned
var updateExtent = function() {
var map = self.selected;
models.map.update(map.getView().calculateExtent(map.getSize()));
triggerExtent();
};
+ //Called as event listener when map is rotated. Update url to reflect rotation reset
+ self.updateRotation = function() {
+ models.map.rotation = self.selected.getView().getRotation();
+ window.history.replaceState("", "@OFFICIAL_NAME@","?" + models.link.toQueryString());
+ }
+
var createMap = function(proj) {
var id = "wv-map-" + proj.id;
var $map = $("<div></div>")
@@ -479,8 +486,10 @@ wv.map.ui = wv.map.ui || function(models, config) {
map.addInteraction(mobileRotation);
}
+ //Set event listeners for changes on the map view (when rotated, zoomed, panned)
map.getView().on("change:center", updateExtent);
map.getView().on("change:resolution", updateExtent);
+ map.getView().on("change:rotation", self.updateRotation);
return map;
};
@@ -507,8 +516,7 @@ 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());
+ self.updateRotation();
});
};
@@ -698,8 +706,7 @@ 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());
+ self.updateRotation();
};
};