Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-300: On a projection switch: - Center point of old projection saved - New projection resize is forced with updateSize - Map recentered to previous center point

Mike McGann945abb8bef27
diff --git a/js/Worldview/Map/ProductMap.js b/js/Worldview/Map/ProductMap.js
index 105d8fc0f..e636311d7 100644
--- a/js/Worldview/Map/ProductMap.js
+++ b/js/Worldview/Map/ProductMap.js
@@ -127,6 +127,9 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {
newMap.events.register("removelayer", self, onRemoveLayer);
newMap.events.register("moveend", self, fireEvent);
newMap.events.register("zoomend", self, onZoomEnd);
+
+ // Keep track of center point on projection switch
+ newMap.previousCenter = newMap.getCenter();
});
productConfigs = mapConfig.products;
@@ -160,10 +163,21 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {
$(".map-projection").css("display", "none");
$(".map-" + projection).css("display", "block");
+ // Keep track of center point on projection switch
+ if ( self.map ) {
+ self.map.previousCenter = self.map.getCenter();
+ }
+
// Update convenience variables
self.map = activeMaps[projection];
self.products = activeProducts[projection];
self.projection = projection;
+
+ // If the browser was resized, the inactive map was not notified of
+ // the event. Force the update no matter what and reposition the center
+ // using the previous value.
+ self.map.updateSize();
+ self.map.setCenter(self.map.previousCenter);
// Ensure the current layers are using the current day if this was
// changed in the last projection