Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Merge

Taylor Gunnoee655c5446f8e
diff --cc .gitignore
index 6c65cbde4,6c65cbde4..c75ba6cc2
--- a/.gitignore
+++ b/.gitignore
@@@ -11,3 -11,3 +11,4 @@@ tool
*~
*.swp
options
++\#*
diff --cc src/css/new-ui.css
index 99695139d,3ec5017de..1fc2992c7
--- a/src/css/new-ui.css
+++ b/src/css/new-ui.css
@@@ -134,6 -134,6 +134,9 @@@ display:inline-block;
.x.axis path {
display: none;
}
++.x.axis .first text{
++ fill:#fff;
++}
.line {
fill: none;
stroke: none;
@@@ -210,59 -209,3 +213,63 @@@ svg#now-line:hover rect.arrow-inner
fill:#222222;
fill-opacity:1;
}
+#zoombtns{
+ position:absolute;
+ z-index:9999;
+ left:280px;
+ bottom:50px;
+ background:rgba(160,160,160,1);
+ cursor:pointer;
+ display:none;
+}
+#zoombtns a{
+ color:#000;
+ margin:0 3px;
+}
+#zoombtns a:hover{
+ text-decoration:underline;
+}
+.selected-int{
+ font-weight:bold;
+ text-decoration:underline;
+}
+#timeline-zoom{
+ position: absolute;
+ z-index: 9999;
+ text-decoration: none;
+ color: black;
+ font-weight: bold;
+ display: inline-block;
+ padding: 5px;
+ right: 10px;
- bottom: 80px;
++ bottom: 80px;
+ background: none repeat scroll 0% 0% rgb(221, 221, 221);
+ height: 15px;
+ border-radius: 7px 7px 7px 7px;
+ border: 1px solid rgb(51, 51, 51);
+ line-height: 15px;
+}
+#timeline-zoom input{
+ width:100px;
+ margin-top:-3px;
+ float:left;
+
+}
+#timeline-hide {
+ vertical-align: middle;
++<<<<<<< Updated upstream
+ display:inline-block;
++=======
++ float: left;
++>>>>>>> Stashed changes
+ background-color:#eee;
+ border-radius:5px;
+ font-size:12px;
+ cursor:pointer;
+ padding:2px;
+ margin-top:-3px;
+}
+#timeline-hide:hover{
+ background-color:#333;
+ color:#eee;
+}
diff --cc src/index.html
index 011c41d80,d51a09a0a..ce91f02c3
--- a/src/index.html
+++ b/src/index.html
@@@ -241,10 -243,6 +243,10 @@@
</footer>
</section>
+ <div id="timeline-zoom">
- <input type="range" max="110" min="10" step="20" value="1" />
++ <input type="range" max="4" min="0" step="1" value="0" id="zoom-slider" />
+ <div id="timeline-hide">Hide Timeline</div>
+ </div>
<svg id="now-line">
<rect
width="3"
diff --cc src/js/date/wv.date.timeline.js
index f387e7514,82ad85a93..320033c93
--- a/src/js/date/wv.date.timeline.js
+++ b/src/js/date/wv.date.timeline.js
@@@ -1,3 -1,3 +1,5 @@@
++
++
/*
* NASA Worldview
*
@@@ -31,13 -31,15 +33,14 @@@ wv.date.timeline = wv.date.timeline ||
var $container;
var model = models.date;
var svg;
-- var timelineJumpInPix;
++ var timelineJumpInPix, zoomScale;
var jumpInterval;
var selectedDateObj;
var selectedDateMs = model.selected.getTime();
var startDateMs = model.start.getTime();
var endDateMs = model.end.getTime();
-
-
+ var buttonInterval = "day";
+
//this is where the data would go for showing available dates
var data = [];
var data2 = [];
@@@ -113,7 -119,7 +117,7 @@@
zoom = d3.behavior.zoom()
.x(x)
.scaleExtent([1, 100])
-- .on("zoom", zoomed);
++ .on("zoom", zoomable, d3.event);
try{
redrawAxis();
@@@ -145,7 -139,7 +149,7 @@@
d3.select(".line2").datum(data2).attr("d", line);
updateTime();
-- d3.select('#timeline footer').call(zoom);
++ d3.select('#timeline footer');
};
var redraw = function(){
//resizing window redrawing goes here
@@@ -163,8 -157,11 +167,8 @@@
x.range([0, width]);
redrawAxis();
-
-
-
};
--
++ //not using
var zoomed = function(){
var t = zoom.translate(),
s = zoom.scale();
@@@ -172,9 -169,21 +176,9 @@@
tx = Math.min(0, Math.max(width * (1 - s), t[0]));
ty = Math.min(0, Math.max(height * (1 - s), t[1]));
zoom.translate([tx, ty]);
-
- svg.select(".x.axis").call(xAxis);
--
- svg.select(".x.grid")
- .call(make_x_axis(x)
- .tickSize(-60, 0, 0)
- .tickFormat(""));
- svg.select(".line")
- .attr("class", "line")
- .attr("d", line);
- svg.select(".line2")
- .attr("class", "line2")
- .attr("d", line);
- updateTimeline();
++
+ redrawAxis();
-
+
if(($("svg#now-line").offset().left) < ($("#timeline footer").offset().left)){
$("svg#now-line").css("visibility","hidden");
@@@ -186,17 -195,46 +190,103 @@@
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
};
--
++ function timeFormat(formats) {
++ return function(date) {
++ var i = formats.length - 1, f = formats[i];
++ while (!f[1](date)) f = formats[--i];
++ return f[0](date);
++ };
++ }
++ function customTickFunction(t0, t1, dt)
++ {
++ console.log(t0);
++ console.log(t1);
++ console.log(dt);
++ var labelSize = 30; // largest label is 23 pixels ("May")
++ var maxTotalLabels = Math.floor(width / labelSize);
++
++ function step(date, offset)
++ {
++ date.setMonth(date.getMonth() + offset);
++ }
++
++ var time = d3.time.month.ceil(t0), times = [], monthFactors = [2,3,4,6];
++
++ while (time < t1) times.push(new Date(+time)), step(time, 1);
++
++ var i;
++ for(i=1 ; times.length > maxTotalLabels ; i++)
++ times = _.filter(times, function(d){
++ return (d.getMonth()) % monthFactors[i] == 0;
++ });
++
++ return times;
++ }
var make_x_axis = function (x) {
return d3.svg.axis()
.scale(x)
.orient("bottom")
- .ticks(7);
- .ticks(10);
++ .ticks(7)//.tickFormat(d3.time.format("%Y %b %d"));
++ .tickFormat(customTimeFormat2);
};
-
-
++ var customTimeFormat = timeFormat([
++ [d3.time.format("%Y"), function() { return true; }],
++ [d3.time.format("%b"), function(d) { return d.getMonth(); }],
++ [function(){return "";}, function(d) { return d.getDate() != 1; }]
++ ]);
++ var customTimeFormat2 = d3.time.format.utc.multi([
++ [".%L", function(d) { return d.getUTCMilliseconds(); }],
++ [":%S", function(d) { return d.getUTCSeconds(); }],
++ ["%I:%M", function(d) { return d.getUTCMinutes(); }],
++ ["%I %p", function(d) { return d.getUTCHours(); }],
++ //["%a %d", function(d) { return d.getUTCDay() && d.getDate() != 1; }],
++ ["%d", function(d) { return d.getUTCDate() != 1; }],
++ ["%b", function(d) { return d.getUTCMonth(); }],
++ ["%Y", function(d) { return true; }],
++ ]);
++ var format = d3.time.format.multi([
++ [".%L", function(d) { return d.getMilliseconds(); }],
++ [":%S", function(d) { return d.getSeconds(); }],
++ ["%I:%M", function(d) { return d.getMinutes(); }],
++ ["%I %p", function(d) { return d.getHours(); }],
++ ["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }],
++ ["%b %d", function(d) { return d.getDate() != 1; }],
++ ["%B", function(d) { return d.getMonth(); }],
++ ["%Y", function() { return true; }]
++ ]);
+
+ var animateForward = function() {
+ if ( ui.anim.active ) {
+ return;
+ }
+ models.date.add(buttonInterval, 1);
+ ui.anim.interval = buttonInterval;
+ ui.anim.play("forward");
+ };
+
+ var animateReverse = function() {
+ if ( ui.anim.active ) {
+ return;
+ }
+ models.date.add(buttonInterval, -1);
+ ui.anim.interval = buttonInterval;
+ ui.anim.play("reverse");
+ };
+
+ var animateEnd = function() {
+ ui.anim.stop();
+ };
+
var init = function() {
setData();
+
+ incrementBtn
+ .mousedown(animateForward)
+ .mouseup(animateEnd);
+ decrementBtn
+ .mousedown(animateReverse)
+ .mouseup(animateEnd);
+
svg = d3.select('#timeline footer')
.append("svg:svg")
.attr('width', width + margin.left + margin.right)
@@@ -246,10 -284,10 +336,27 @@@
.attr("class", "line2")
.attr("d", line);
++
++
++ var firstTick = svg.select(".x.axis .tick:first-child text");
++ var firstTickData = firstTick.data()[0];
++ console.log(firstTickData.getUTCFullYear());
++ svg.select(".x.axis").insert("g",":first-child")
++ .attr("class", "first")
++ .attr("transform", "translate(5," + 23 + ")")
++ .append("text").text(firstTickData.getUTCFullYear());
++
++
updateTimeline();
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
++
++ if (zoom.scale() === 1){
++ console.log("True!");
++ }
++ console.log((new Date(2014, 0, 1) - new Date(2011, 0, 1))/DAY_IN_MS);
++
// Hover line.
hoverLineGroup = svg.append("g")
.attr("class", "hover-line");
@@@ -278,12 -315,8 +385,17 @@@
mouse_x_start = d3.mouse(this)[0];
var mouse_x_jump = mouse_x_start + timelineJump;
console.log("$$$$$$$$$$$$ ");
- })*/;
-
+ })*/
+ d3.select("#timeline footer svg")
- .on("mousewheel.zoom", zoomable)
- .on("DOMMouseScroll.zoom", zoomable)
- .on("dblclick.zoom", zoomable);
++ .on("mousewheel.zoom", null)
++ .on("DOMMouseScroll.zoom", null)
++ .on("dblclick.zoom", null)
++ .on("onwheel",null)
++ .on("mousewheel",null)
++ .on("onmousewheel",null)
++ .on("wheel",null)
++ .on("MozMousePixelScroll",null);
+
$("svg#now-line")
.mousedown(function(e){
e.preventDefault();
@@@ -380,66 -412,8 +491,103 @@@
}
}
});
- $("#zoombtns #all").click(function(e){
- zoom.scale(10);
- s = zoom.scale();
- tx = Math.min(0, width * (1 - s));
- ty = Math.min(0, height * (1 - s));
- zoom.translate([tx, ty]);
- redrawAxis();
- $("#zoombtns a").removeClass("selected-int");
- $(this).addClass("selected-int");
-
- });
+
+ $("#timeline-zoom").hover(function(e){
+ $("#timeline footer").css("background","rgba(40,40,40,0.9)");
+ },function(e){
+ $("#timeline footer").css("background","");
+ });
+ $("#timeline-zoom input").on("input",function(e){
- console.log("instant change");
- if (zoom.scale === $(this).val()){
- console.log("no change!");
- return;
- }
- else{
- var finalVal = Math.pow(($(this).val() / 10),2);
- zoom.scale(finalVal);
- s = zoom.scale();
- tx = Math.min(0, width * (1 - s));
- ty = Math.min(0, height * (1 - s));
++ var testZoomLevel = $(this).val();
++ if (zoomLevel != testZoomLevel){
++ switch(testZoomLevel){
++ case '0':
++ zoomScale = 1;
++ break;
++
++ case '1':
++ zoomScale = 2;
++ break;
++ case '2':
++ zoomScale = 4;
++ break;
++ case '3':
++ zoomScale = 20;
++ break;
++ case '4':
++ zoomScale = 60;
++ break;
++ default:
++ console.log("Doesn't work");
++ }
++ //console.log(zoom.scale());
++ zoomLevel = testZoomLevel;
++ zoom.scale(zoomScale);
++ tx = Math.min(0, width * (1 - zoomScale));
++ ty = Math.min(0, height * (1 - zoomScale));
+ zoom.translate([tx, ty]);
+ redrawAxis();
++ var firstTickZ = svg.select(".x.axis .tick:nth-child(2) text");
++ var firstTickDataZ = firstTickZ.data()[0];
++ console.log(firstTickZ);
++ if ((zoomScale === 20) || (zoomScale === 60)){
++ console.log("Correct" + firstTickDataZ.getUTCMonth());
++ svg.select(".x.axis .first text").text(firstTickDataZ.getUTCFullYear() +
++ " " + monthNames[firstTickDataZ.getUTCMonth()]);
++ }
++ else{
++
++ svg.select(".x.axis .first text").text(firstTickDataZ.getUTCFullYear());
++
++ }
+ }
- }).on("change",function(e){
- console.log("change after mouse release");
+ });
+ $("#timeline-hide").click(function(e){
+ var tl = $("#timeline footer");
+ if(tl.is(":hidden"))
+ {
+ tl.show("slow");
+ $("#timeline-zoom input").show();
+ $("#timeline-hide").text("Hide Timeline");
+ $("#timeline-zoom").css("right","10px");
+ $("#timeline-zoom").css("left","auto");
- $("#now-line").hide();
++ $("#now-line").show();
+
+ }
+ else{
+ tl.hide("slow");
+ $("#timeline-zoom input").hide();
+ $("#timeline-hide").text("Show Timeline");
++ $("#timeline-zoom").css("left","183px");
+ $("#timeline-zoom").css("right","auto");
- $("#timeline-zoom").css("left","180px");
+ $("#now-line").hide();
+ }
+
+ });
++
}; // /init
- var zoomable = function(){
- console.log("derr");
++ var incrementZoom = function(){
++
++ };
++ var zoomable = function(e){
++ var tempVal;
++ var sliderVal = parseInt($("#timeline-zoom input").val());
++
++ var evt = window.event || d3.event.sourceEvent || e;
++ var delta=evt.deltaY ? evt.deltaY : evt.wheelDeltaY || evt.detail ? evt.detail*(-120) : evt.wheelDelta;
++ if (delta < 0){
++
++ tempVal = sliderVal + 1;
++ }
++ else{
++ tempVal = sliderVal - 1;
++ }
++ if ((tempVal >= 0) && (tempVal <= 4)){
++ $("#timeline-zoom input").val(tempVal).trigger("input");
++ }
++ else
++ return;
+ };
var bindTimelineMouseMove = function() {
var mouse_x = d3.mouse(this)[0];
var graph_x = x.invert(mouse_x);