Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Zoom out or move map indicator

Mike McGann708feb4e1f7c
diff --git a/web/js/data/wv.data.ui.js b/web/js/data/wv.data.ui.js
index 16c21eba3..1cb6c51d5 100644
--- a/web/js/data/wv.data.ui.js
+++ b/web/js/data/wv.data.ui.js
@@ -182,8 +182,9 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
}
};
- self.onViewChange = function(map) {
+ self.onViewChange = function() {
var indicator;
+ var map = ui.map.selected;
if ( !model.active || queryActive || !lastResults ) {
return;
@@ -193,11 +194,13 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
}
var hasCentroids = false;
var inView = false;
- var extent = map.getExtent().toGeometry();
+ var extent = map.getView().calculateExtent(map.getSize());
+ var crs = models.proj.selected.crs;
_.each(lastResults.granules, function(granule) {
- if ( granule.centroid && granule.centroid[map.projection] ) {
+ if ( granule.centroid && granule.centroid[crs] ) {
hasCentroids = true;
- if ( extent.intersects(granule.centroid[map.projection]) ) {
+ if ( ol.extent.intersects(extent,
+ granule.centroid[crs].getExtent()) ) {
inView = true;
return true;
}
diff --git a/web/js/map/wv.map.ui.js b/web/js/map/wv.map.ui.js
index 3cfc62d6a..a709e4bea 100644
--- a/web/js/map/wv.map.ui.js
+++ b/web/js/map/wv.map.ui.js
@@ -339,9 +339,14 @@ wv.map.ui = wv.map.ui || function(models, config) {
}
};
+ var triggerExtent = _.throttle(function() {
+ self.events.trigger("extent");
+ }, 500, { trailing: true });
+
var updateExtent = function() {
var map = self.selected;
models.map.update(map.getView().calculateExtent(map.getSize()));
+ triggerExtent();
};
var createMap = function(proj) {
diff --git a/web/js/wv.main.js b/web/js/wv.main.js
index b82e76f3d..66fb2bf85 100644
--- a/web/js/wv.main.js
+++ b/web/js/wv.main.js
@@ -180,26 +180,20 @@ $(function() {
$("#eventsHolder").hide();
// Wirings
- /* FIXME: OL3
if ( config.features.dataDownload ) {
models.data.events
.on("activate", function() {
ui.sidebar.selectTab("download");
})
.on("queryResults", function() {
- ui.data.onViewChange(ui.map.selected);
+ ui.data.onViewChange();
});
- ui.map.events
- .on("moveEnd", function(map) {
- ui.data.onViewChange(map);
- })
- .on("zoomEnd", function(map) {
- ui.data.onViewChange(map);
- });
- // FIXME: This is a hack
- models.map.events.on("projection", models.data.updateProjection);
+ ui.map.events.on("extent", function() {
+ ui.data.onViewChange();
+ });
+ // FIXME: This is a hack
+ models.map.events.on("projection", models.data.updateProjection);
}
- */
// Sink all focus on inputs if click unhandled
$(document).click(function(event) {