Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fixed issue with zoom ability disappearing after loading a new layer

Taylor Gunnoe765cf919917a
diff --git a/src/css/new-ui.css b/src/css/new-ui.css
index c8a415d4b..e9f0a14ff 100644
--- a/src/css/new-ui.css
+++ b/src/css/new-ui.css
@@ -14,6 +14,7 @@
position:absolute;
bottom:10px;
left:10px;
+ border:1px solid #333;
}
#timeline footer text{
font-size:16px;
diff --git a/src/js/date/wv.date.timeline.js b/src/js/date/wv.date.timeline.js
index 41b122418..aeb5daf20 100644
--- a/src/js/date/wv.date.timeline.js
+++ b/src/js/date/wv.date.timeline.js
@@ -65,40 +65,40 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
var setData = function(){
- data = [
- {
- "date": model.start,
- "value": "5"
- },
- {
- "date": model.end,
- "value": "5"
- }
- ];
- //Current date line
- data2 = [
+ data = [
{
- "date": model.selected.getTime(),
- "value": "0"
+ "date": model.start,
+ "value": "5"
},
- {
- "date": model.selected.getTime(),
- "value": "6"
+ {
+ "date": model.end,
+ "value": "5"
}
- ];
- x = d3.time.scale()
+ ];
+ //Current date line
+ data2 = [
+ {
+ "date": model.selected.getTime(),
+ "value": "0"
+ },
+ {
+ "date": model.selected.getTime(),
+ "value": "6"
+ }
+ ];
+ x = d3.time.scale()
.domain([
d3.min(data, function(d) { return d.date; }),
d3.max(data, function(d) { return d.date; })
])
.range([0, width]);
- y = d3.scale.linear()
+ y = d3.scale.linear()
.domain(d3.extent(data2, function (d) {
return d.value;
}))
.range([height, 0]);
- line = d3.svg.line()
+ line = d3.svg.line()
.x(function (d) {
return x(d.date);
})
@@ -106,31 +106,35 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
return y(d.value);
});
- xAxis = d3.svg.axis()
+ xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.ticks(10);
- try{
- redrawAxis();
- }
- catch(e){
- console.log("error is following:" + e);
- }
- zoom = d3.behavior.zoom()
+
+ zoom = d3.behavior.zoom()
.x(x)
.scaleExtent([1, 100])
.on("zoom", zoomed);
+
+ try{
+ redrawAxis();
+ }
+ catch(e){
+ console.log("error is following:" + e);
+ }
+
};
var redrawAxis = function(){
- d3.select(".axis").call(xAxis);
+ d3.select(".axis").call(xAxis);
d3.select(".grid").call(make_x_axis(x).tickSize(-60, 0, 0));
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
d3.select(".line").datum(data).attr("d", line);
d3.select(".line2").datum(data2).attr("d", line);
- updateTime();
- svg = d3.select('#timeline footer').call(zoom);
+ updateTime();
+
+ d3.select('#timeline footer').call(zoom);
};
var redraw = function(){
//resizing window redrawing goes here
@@ -159,7 +163,6 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
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);
@@ -174,7 +177,6 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
svg.select(".line2")
.attr("class", "line2")
.attr("d", line);
-
updateTimeline();
if(($("svg#now-line").offset().left) < ($("#timeline footer").offset().left)){
@@ -187,7 +189,6 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
}
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
-
};
var make_x_axis = function (x) {
@@ -199,9 +200,7 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
var init = function() {
- console.log("setting data...");
- setData();
- console.log("data set!");
+ setData();
svg = d3.select('#timeline footer')
.append("svg:svg")
.attr('width', width + margin.left + margin.right)
@@ -363,9 +362,9 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
model.events.on("select", function(){
updateTime();
});
- models.layers.events.on("change",function(){
- setData();
- });
+ models.layers.events.on("change",function(){
+ setData();
+ });
updateTime();
$('#day-input-group').addClass('button-input-group-selected');
bindBtnsToDay();
@@ -435,12 +434,12 @@ wv.date.timeline = wv.date.timeline || function(models, config) {
});
};
var updateTimeline = function(){
- //update timeline line
- svg.select(".line2").attr("d", line);
- var makeFill = d3.select('.line2').attr("d");
- d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
- var makeFillPos = $(".line2").offset();
- $("svg#now-line").css("left", (makeFillPos.left-3) + "px");
+ //update timeline line
+ svg.select(".line2").attr("d", line);
+ var makeFill = d3.select('.line2').attr("d");
+ d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
+ var makeFillPos = $(".line2").offset();
+ $("svg#now-line").css("left", (makeFillPos.left-3) + "px");
};
var updateTime = function() {
$('#year-input-group').val(model.selected.getUTCFullYear());