Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

If time is invalid, now defaults to today

Mike McGann78a76ab9f1aa
diff --git a/js/Worldview/Widget/Map.js b/js/Worldview/Widget/Map.js
index c147234bf..a25284c5d 100644
--- a/js/Worldview/Widget/Map.js
+++ b/js/Worldview/Widget/Map.js
@@ -113,7 +113,9 @@ Worldview.Widget.Map = function(containerId, spec) {
*/
self.loadFromQuery = function(queryString) {
log.debug("loadFromQuery: " + queryString);
+ var query = Worldview.queryStringToObject(queryString);
self.updateComponent(queryString);
+ self.setValue(query.map);
};
/**
diff --git a/js/Worldview/Widget/WorldviewMap.js b/js/Worldview/Widget/WorldviewMap.js
index 9c6e4cdd8..6e7c5c22c 100644
--- a/js/Worldview/Widget/WorldviewMap.js
+++ b/js/Worldview/Widget/WorldviewMap.js
@@ -76,7 +76,8 @@ Worldview.Widget.WorldviewMap = function(containerId, spec) {
log.debug(state);
- if ( state["switch"] !== last["switch"] ) {
+ if ( state["switch"] !== undefined &&
+ state["switch"] !== last["switch"] ) {
var projection = state["switch"];
if ( !(projection in self.productMap.mapConfig.projections) ) {
var defaultProjection =
@@ -91,6 +92,15 @@ Worldview.Widget.WorldviewMap = function(containerId, spec) {
self.productMap.set(state.products);
}
if ( state.time !== last.time ) {
+ if ( state.time === undefined ) {
+ state.time = SOTE.util.ISO8601StringFromDate(new Date());
+ }
+ var date = new Date(state.time);
+ if ( isNaN(date.getTime()) ) {
+ log.warn("Invalid time: " + state.time + ", using today");
+ state.time = SOTE.util.ISO8601StringFromDate(new Date());
+ date = new Date();
+ }
self.productMap.setDay(new Date(state.time));
}
diff --git a/js/dateSpan.js b/js/dateSpan.js
index b310420fa..66d2ff68a 100644
--- a/js/dateSpan.js
+++ b/js/dateSpan.js
@@ -26,6 +26,7 @@ SOTE.namespace("SOTE.widget.DateSpan");
*
*/
SOTE.widget.DateSpan = function(containerId, config){
+ this.log = Logging.Logger("Worldview.Widget.DateSpan");
this.SLIDER_WIDTH = 1000;
this.DAY_IN_MS = 24*60*60*1000;
this.sliders = new Object();
@@ -469,6 +470,18 @@ SOTE.widget.DateSpan.prototype.setValue = function(value){
value = SOTE.util.ISO8601StringFromDate(new Date());
}
var vals = SOTE.util.getValuesFromISO8601String(value);
+ // Check to see if the date is valid, if not default to today
+ var valid = true;
+ $.each(vals, function(index, value) {
+ if ( isNaN(value) ) {
+ value = SOTE.util.ISO8601StringFromDate(new Date());
+ vals = SOTE.util.getValuesFromISO8601String(value);
+ valid = false;
+ }
+ });
+ if ( ! valid ) {
+ this.log.warn("Invalid time: " + value + ", using today");
+ }
if(vals[2] > this.months[vals[1]]){
vals[2] = this.months[vals[1]];
}