Interactive interface for browsing global, full-resolution satellite imagery
If extent is invalid in setValue, it uses the previous value
Mike McGanna819edad6871
diff --git a/js/Worldview/Map.js b/js/Worldview/Map.jsindex cf3431ae4..b4eadd962 100644--- a/js/Worldview/Map.js+++ b/js/Worldview/Map.js@@ -51,5 +51,18 @@ $(function(ns) {},})};++ ns.isExtentValid = function(extent) {+ if ( extent === undefined ) {+ return false;+ }+ var valid = true;+ $.each(extent.toArray(), function(index, value) {+ if ( isNaN(value) ) {+ valid = false;+ }+ });+ return valid;+ }}(Worldview.Map));diff --git a/js/Worldview/Widget/Map.js b/js/Worldview/Widget/Map.jsindex cf75e8377..bee9d6642 100644--- a/js/Worldview/Widget/Map.js+++ b/js/Worldview/Widget/Map.js@@ -65,8 +65,22 @@ Worldview.Widget.Map = function(containerId, spec) {* Y value. Commas instead of underscores are also accepted.*/self.setValue = function(value) {- log.debug("setValue: " + extent);+ if ( value === undefined ) {+ return;+ }++ log.debug("setValue: " + value);var extent = OpenLayers.Bounds.fromString(value);+ var map = self.productMap.map;++ // Verify that the viewport extent overlaps the valid extent, if+ // invalid, just zoom out the max extent+ if ( !Worldview.Map.isExtentValid(extent) ||+ !extent.intersectsBounds(map.getExtent()) ) {+ log.warn("Extent is invalid: " + extent + "; using " ++ map.getExtent());+ extent = map.getExtent();+ }self.productMap.map.zoomToExtent(extent, true);};