Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Image download palette dialog now continues to crop if the user selects yes

Mike McGann966593af166a
diff --git a/js/Worldview/Map/ProductMap.js b/js/Worldview/Map/ProductMap.js
index e564e4c44..9a14fe1d5 100644
--- a/js/Worldview/Map/ProductMap.js
+++ b/js/Worldview/Map/ProductMap.js
@@ -45,6 +45,10 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {
// Display products on the map for this day
var currentDay = new Date();
+ // The number of layers in the processing of loading. This is used
+ // to fire maploadstart and maploadend events.
+ var layersLoading = 0;
+
//-------------------------------------------------------------------------
// Public
//-------------------------------------------------------------------------
@@ -114,8 +118,8 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {
activeMaps[projection] = newMap;
activeProducts[projection] = [];
- newMap.events.register("addlayer", self, refreshZOrder);
- newMap.events.register("removelayer", self, refreshZOrder);
+ newMap.events.register("addlayer", self, onAddLayer);
+ newMap.events.register("removelayer", self, onRemoveLayer);
newMap.events.register("moveend", self, fireEvent);
newMap.events.register("zoomend", self, onZoomEnd);
});
@@ -476,6 +480,27 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {
.css("color", "#FFFFFF");
}
};
+
+ var onAddLayer = function(event) {
+ var layer = event.layer;
+ layer.events.register("loadstart", layer, function() {
+ if ( layersLoading === 0 ) {
+ self.map.events.triggerEvent("maploadstart");
+ }
+ layersLoading++;
+ });
+ layer.events.register("loadend", layer, function() {
+ layersLoading--;
+ if ( layersLoading === 0 ) {
+ self.map.events.triggerEvent("maploadend");
+ }
+ });
+ refreshZOrder();
+ };
+
+ var onRemoveLayer = function(event) {
+ refreshZOrder();
+ };
init();
return self;
diff --git a/js/main.js b/js/main.js
index 4dc599d12..4139f18b5 100644
--- a/js/main.js
+++ b/js/main.js
@@ -37,7 +37,7 @@ $(function() {// Initialize "static" vars
//var tr = new SOTE.widget.MenuPicker("transition",{dataSourceUrl:"data/mp_transition.php"});
var map = new SOTE.widget.DateSpan("time",{hasThumbnail:false});
//Image download variables
- rb = new SOTE.widget.RubberBand("camera",{icon:"images/camera.png",onicon:"images/cameraon.png",cropee:"map",paletteWidget:palettes});
+ rb = new SOTE.widget.RubberBand("camera",{icon:"images/camera.png",onicon:"images/cameraon.png",cropee:"map",paletteWidget:palettes,mapWidget:m});
var id = new SOTE.widget.ImageDownload("imagedownload",{baseLayer:"MODIS_Terra_CorrectedReflectance_TrueColor",alignTo: rb, m:m});
// Get rid of address bar on iphone/ipod
diff --git a/js/rubberBand.js b/js/rubberBand.js
index ac1f6321c..edeece060 100644
--- a/js/rubberBand.js
+++ b/js/rubberBand.js
@@ -36,6 +36,7 @@ SOTE.widget.RubberBand = function (containerId, config){
this.id = containerId;
this.state = "off";
this.jcropAPI = null;
+ this.mapWidget = config.mapWidget;
this.paletteWidget = config.paletteWidget;
this.palettesActive = false;
//this.windowURL = "";
@@ -69,21 +70,33 @@ SOTE.widget.RubberBand.prototype.init = function(){
SOTE.widget.RubberBand.toggle = function(o){
var self = o.data.self;
-
+
+ var toggleOn = function() {
+ self.state = "on";
+ $("#"+self.id+"camera_link img").attr("src",self.onicon);
+ $("#imagedownload").show('slide', {direction: 'up'}, 1000);
+ self.draw();
+ };
+
+ var disablePalettes = function() {
+ var map = self.mapWidget.productMap.map;
+ var handler = function() {
+ map.events.unregister("maploadend", map, handler);
+ toggleOn();
+ };
+ map.events.register("maploadend", map, handler);
+ self.paletteWidget.setValue("");
+ };
+
if(self.state == "off" && self.projectionSwitch == "geographic"){
if (self.palettesActive) {
Worldview.ask({
header: "Notice",
message: self.PALETTE_WARNING,
- onYes: function() {
- self.paletteWidget.setValue("");
- }
+ onYes: disablePalettes
});
} else {
- self.state = "on";
- $("#"+self.id+"camera_link img").attr("src",self.onicon);
- $("#imagedownload").show('slide', {direction: 'up'}, 1000);
- self.draw();
+ toggleOn();
}
}
else if(self.projectionSwitch == "geographic"){