Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Adjusted styling at dateline #110

Benjaminca37cb9070b8
diff --git a/web/css/wv.dateline.css b/web/css/wv.dateline.css
index c6691b5aa..75ab0eee9 100644
--- a/web/css/wv.dateline.css
+++ b/web/css/wv.dateline.css
@@ -2,5 +2,11 @@
stroke:rgb(0, 0, 0);
stroke-width: 2;
stroke-dasharray: 10, 5;
-
+}
+.dateline-text {
+ pointer-events: none;
+ display: block;
+}
+.ol-overlay-container {
+ pointer-events: none;
}
\ No newline at end of file
diff --git a/web/js/map/wv.map.datelinebuilder.js b/web/js/map/wv.map.datelinebuilder.js
index 0bde63f61..f4358daa1 100644
--- a/web/js/map/wv.map.datelinebuilder.js
+++ b/web/js/map/wv.map.datelinebuilder.js
@@ -11,6 +11,7 @@
* Licensed under the NASA Open Source Agreement, Version 1.3
* http://opensource.gsfc.nasa.gov/nosa.php
*/
+ /*eslint no-unused-vars: "error"*/
var wv = wv || {};
wv.map = wv.map || {};
@@ -19,12 +20,10 @@ wv.map = wv.map || {};
*/
wv.map.datelinebuilder = wv.map.ui || function(models, config) {
var self = {};
- var line1, line2, overlay1, overlay2, textArray, svg1, svg2, textOverlay1, textOverlay2;
+ var line1, line2, map, overlay1, overlay2, svg1, svg2;
-
-
- self.init = function(Parent, map, date) {
- textArray = [];
+ self.init = function(Parent, olMap, date) {
+ map = olMap;
drawDatelines(map, date);
Parent.events.on('moveend', function() {
@@ -39,27 +38,13 @@ wv.map.datelinebuilder = wv.map.ui || function(models, config) {
var svg, line;
svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
line = document.createElementNS("http://www.w3.org/2000/svg","line");
- svg.setAttribute('width', '5');
+ svg.setAttribute('width', '3');
setLineDefaults(line);
-
- svg.addEventListener("mouseover", function( event ) {
- line.setAttribute('stroke-dasharray', 'none');
- line.setAttribute('stroke-width', '5');
- line.setAttribute('opacity', '1');
- offsetText(map);
- });
- svg.addEventListener("mouseout", function( event ) {
- line.setAttribute('stroke-dasharray', '10, 5');
- line.setAttribute('stroke-width', '3');
- line.setAttribute('opacity', '0.7');
- });
-
-
svg.appendChild(line);
-
svg.setAttribute('class', classes);
+
return [svg, line];
};
var drawText = function(date) {
@@ -69,10 +54,11 @@ wv.map.datelinebuilder = wv.map.ui || function(models, config) {
leftText = document.createElementNS("http://www.w3.org/2000/svg", "text");
rightText = document.createElementNS("http://www.w3.org/2000/svg", "text");
svg.setAttribute('style','transform: translate(-100px,0);');
+ svg.setAttribute('class', 'dateline-text');
svg.setAttribute('width', '200');
- rightText.append(document.createTextNode(wv.util.toISOStringDate(wv.util.dateAdd(date, 'day', 1))));
- leftText.append(document.createTextNode(wv.util.toISOStringDate(date)));
-
+ svg.setAttribute('class', 'dateline-text hidden');
+ leftText.append(document.createTextNode(wv.util.toISOStringDate(wv.util.dateAdd(date, 'day', 1))));
+ rightText.append(document.createTextNode(wv.util.toISOStringDate(date)));
setTextDefaults(rightText, 110);
setTextDefaults(leftText, 15);
@@ -98,14 +84,11 @@ wv.map.datelinebuilder = wv.map.ui || function(models, config) {
svgEl.setAttribute('fill', 'white');
svgEl.setAttribute('stroke', 'black');
svgEl.setAttribute('stroke-width', '0.5');
- svgEl.setAttribute('opacity', '1');
- };
- var positionTextVertically = function(textEl, y2) {
- textEl.setAttribute('y', y2);
};
var drawDatelines = function(map, date) {
- var $obj1, $obj2, viewport, defaultCoord;
-
+ var $obj1, $obj2, viewport, defaultCoord, textSvg1, textSvg2,
+ textOverlay1, textOverlay2;
+
defaultCoord = [-180, 90];
obj1 = drawLines('dateline_left dateline');
obj2 = drawLines('dateline_right dateline');
@@ -113,30 +96,53 @@ wv.map.datelinebuilder = wv.map.ui || function(models, config) {
line2 = obj2[1];
svg1 = obj1[0];
svg2 = obj2[0];
+ textSvg1 = drawText(date);
+ textSvg2 = drawText(wv.util.dateAdd(date, 'day', -1));
+ textOverlay1 = drawOverlay(defaultCoord, textSvg1);
+ textOverlay2 = drawOverlay(defaultCoord, textSvg2);
overlay1 = drawOverlay(defaultCoord, obj1[0]);
overlay2 = drawOverlay(defaultCoord, obj2[0]);
- textOverlay1 = drawOverlay(defaultCoord,drawText(date));
- textOverlay2 = drawOverlay(defaultCoord, drawText(wv.util.dateAdd(date, 'day', -1)));
+
map.addOverlay(overlay1);
map.addOverlay(overlay2);
map.addOverlay(textOverlay1);
map.addOverlay(textOverlay2);
+
+ setListeners(svg1, textSvg1, textOverlay1, -180);
+ setListeners(svg2, textSvg2, textOverlay2, 180);
+ };
+ var setListeners = function(lineSVG, textSVG, overlay, lineX) {
+ var line = lineSVG.childNodes[0];
+ lineSVG.addEventListener("mouseover", function(e) {
+ var pixels, coords;
+ pixels = [e.pageX,e.pageY];
+ coords = map.getCoordinateFromPixel(pixels);
+ line.setAttribute('stroke-dasharray', 'none');
+ line.setAttribute('opacity', '1');
+ textSVG.setAttribute('class', 'dateline-text');
+ overlay.setPosition([lineX, coords[1]]);
+ });
+ lineSVG.addEventListener("mouseout", function( event ) {
+ line.setAttribute('stroke-dasharray', '10, 5');
+ line.setAttribute('opacity', '0.7');
+ textSVG.setAttribute('class', 'dateline-text hidden');
+ });
};
var position = function(map) {
- var extent, top, topY, bottomY, bottom, height, startY, ninetyDegreePixel, topExtent, bottomExtent, halfHeight, halfStart;
-
- if(map.getSize()[0] === 0) {
- return;
- }
- extent = map.getView().calculateExtent(map.getSize());
- top = [extent[2] -1, extent[3]];
- bottom = [extent[2] -1, extent[1]];
- topExtent = map.getPixelFromCoordinate([extent[2] -1, extent[3] - 1]);
- bottomExtent = map.getPixelFromCoordinate([extent[0] + 1, extent[1] + 1]);
- topY = Math.round(topExtent[1]);
- bottomY = Math.round(bottomExtent[1]);
- startY = Math.round(extent[3]);
+ var extent, top, topY, bottomY, bottom, height, startY, ninetyDegreePixel, topExtent, bottomExtent, halfHeight, halfStart;
+
+ if(map.getSize()[0] === 0) {
+ return;
+ }
+ extent = map.getView().calculateExtent(map.getSize());
+ top = [extent[2] -1, extent[3] + 5];
+ bottom = [extent[2] -1, extent[1] - 5];
+ topExtent = map.getPixelFromCoordinate([extent[2] -1, extent[3] - 1]);
+ bottomExtent = map.getPixelFromCoordinate([extent[0] + 1, extent[1] + 1]);
+ topY = Math.round(topExtent[1] + 5);
+ bottomY = Math.round(bottomExtent[1] - 5);
+ startY = Math.round(extent[3] + 5);
if (startY > 90) {
startY = 90;
@@ -155,8 +161,7 @@ wv.map.datelinebuilder = wv.map.ui || function(models, config) {
overlay1.setPosition([-180, startY]);
overlay2.setPosition([180, startY]);
- textOverlay1.setPosition([-180, halfStart]);
- textOverlay2.setPosition([180, halfStart]);
+
update(height);
};
var drawOverlay = function(coordinate, el) {