Interactive interface for browsing global, full-resolution satellite imagery
Remove points correctly
Taylor Gunnoeda5b1b26d6c9
diff --git a/web/js/naturalEvents/wv.naturalEvents.map.js b/web/js/naturalEvents/wv.naturalEvents.map.jsindex eb4026bf9..e201e4c6d 100644--- a/web/js/naturalEvents/wv.naturalEvents.map.js+++ b/web/js/naturalEvents/wv.naturalEvents.map.js@@ -12,15 +12,16 @@var wv = wv || {};wv.naturalEvents = wv.naturalEvents || {};-wv.naturalEvents.map = wv.naturalEvents.map || function(location, map) {+wv.naturalEvents.map = wv.naturalEvents.map || function(models, maps, config) {var self = {};- vectorLayer = null;+ var vectorLayer = null;+ var map = null;+ self.current = null;var init = function() {- model.events- .on("select", onSelect);+};var getButtonDimensions = function() {var zoom = map.getView().getZoom();@@ -48,32 +49,73 @@ wv.naturalEvents.map = wv.naturalEvents.map || function(location, map) {})})];};+ var fillStyle = function(feature){+ return [new ol.style.Style({+ fill: new ol.style.Fill({+ color: [255, 255, 255, .1]+ }),+ stroke: new ol.style.Stroke({+ color: [212, 85, 0, .8],+ width: 2+ })+ })]+ };var onSelect = function(){+ };++ self.draw = function(location) {++ //loads current map+ if (!map) {+ map = maps.selected;+ }++ //remove any existing location firstmap.removeLayer(vectorLayer);+ //Polygon or point?+ var style, geoms;+ if (location[0].length > 2){+ geoms = new ol.geom.Polygon(location);+ style = fillStyle;+ }+ else {+ geoms = new ol.geom.Point(location);+ style = buttonStyle;+ }var iconFeature = new ol.Feature({- geometry: new ol.geom.Point(location),+ geometry: geoms,name: 'NaturalEvent',population: 4000,rainfall: 500});- iconFeature.setStyle(buttonStyle);+ iconFeature.setStyle(style);var vectorSource = new ol.source.Vector({features: [iconFeature],wrapX: false});- var vectorLayer = new ol.layer.Vector({+ vectorLayer = new ol.layer.Vector({source: vectorSource});+map.addLayer(vectorLayer);+ //save last selected location+ self.current = location;++ };++ var dispose = function(){+ map.removeLayer(vectorLayer);};+ //make dispose available to naturalEvents.ui+ self.dispose = dispose;- onSelect();+ init();return self;};diff --git a/web/js/naturalEvents/wv.naturalEvents.ui.js b/web/js/naturalEvents/wv.naturalEvents.ui.jsindex 827991f8b..4f25e0ba8 100644--- a/web/js/naturalEvents/wv.naturalEvents.ui.js+++ b/web/js/naturalEvents/wv.naturalEvents.ui.js@@ -5,7 +5,7 @@* This code was originally developed at NASA/Goddard Space Flight Center for* the Earth Science Data and Information System (ESDIS) project.*- * Copyright (C) 2013 - 2014 United States Government as represented by the+ * Copyright (C) 2013 - 2017 United States Government as represented by the* Administrator of the National Aeronautics and Space Administration.* All Rights Reserved.*/@@ -18,9 +18,13 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config) {var self = {};var model = models.naturalEvents;var data;+ var zoomLevel;self.selector = "#wv-events";self.id = "wv-events";+ var maps = ui.map;var map = ui.map.selected;+ //load naturalEvents.map+ var mapController = wv.naturalEvents.map(models, maps, config);//Local storage may not be a good idea because they'll never see it again//wv.util.localStorage('notified') || false;@@ -36,9 +40,12 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config) {ui.sidebar.events.on("select", function(tab) {if ( tab === "events" ) {resize();+ if (mapController.current) {+ mapController.draw(mapController.current);+ }}else {-+ mapController.dispose();}});$(window).resize(resize);@@ -149,7 +156,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config) {});// Bind click event to each event- $(self.selector + "content li").click(function() {+ $(self.selector + "content li").toggle( function() {var dataIndex = $(this).attr("data-index");showEvent(dataIndex);$(self.selector + "content li").removeClass('item-selected');@@ -158,6 +165,11 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config) {ui.sidebar.collapseNow();}notify();+ }, function(){+ $(self.selector + "content li").removeClass('item-selected');+ hideEvent();+ mapController.dispose();+ mapController.current = null;});//Bind click event to each date contained in events with dates@@ -259,7 +271,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config) {zoomLevel = 6;}var callback = function(){- wv.naturalEvents.map(eventItem.coordinates, map);+ mapController.draw(eventItem.coordinates);};if ( eventItem.type === "Point" ) {ui.map.animate.move(method, eventItem.coordinates, zoomLevel, callback);@@ -353,6 +365,11 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config) {self.select(index, dateIndex);};+ var hideEvent = function() {+ $("#wv-eventscontent .subtitle").hide();+ $("#wv-eventscontent .dates").hide();+ resize();+ }var notify = function( text ) {var message = text || 'Events may not be visible at all times. Read more...';