Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add polar zoom support, fix lint errors

Ed Platod1bbbd37763e
diff --git a/web/js/map/animate.js b/web/js/map/animate.js
index 155ba27a9..50452a0b4 100644
--- a/web/js/map/animate.js
+++ b/web/js/map/animate.js
@@ -21,7 +21,8 @@ export function mapAnimate(models, config, ui) {
var hasEndInView = olExtent.containsCoordinate(extent, endPoint);
var line = new OlGeomLineString([startPoint, endPoint]);
var distance = line.getLength(); // In map units, which is usually degrees
- var duration = (distance * 20) + 1000; // 4.6 seconds to go 360 degrees
+ distance = distance > 1000 ? distance / 100000 : distance; // limit large polar projection distances from coordinate transforms
+ var duration = Math.floor((distance * 20) + 1000); // 4.6 seconds to go 360 degrees
var animationPromise = function () {
var args = Array.prototype.slice.call(arguments);
return new Promise(function (resolve, reject) {
diff --git a/web/js/natural-events/markers.js b/web/js/natural-events/markers.js
index 617e2060c..a81667e80 100644
--- a/web/js/natural-events/markers.js
+++ b/web/js/natural-events/markers.js
@@ -82,66 +82,66 @@ export default function markers (models, ui) {
? category
: { title: 'Default', slug: 'default' };
- // get maxExtent of current projection and check if marker is within range
+ // get maxExtent of current projection and check if marker is within range
let maxExtent = models.proj.selected.maxExtent;
- let maxExtentCheck = coordinates[0] >= maxExtent[0]
- && coordinates[0] <= maxExtent[2]
- && coordinates[1] >= maxExtent[1]
- && coordinates[1] <= maxExtent[3];
+ let maxExtentCheck = coordinates[0] >= maxExtent[0] &&
+ coordinates[0] <= maxExtent[2] &&
+ coordinates[1] >= maxExtent[1] &&
+ coordinates[1] <= maxExtent[3];
// only create marker if within projection extent range
if (maxExtentCheck) {
marker.pin = createPin(event.id, category, isSelected);
marker.pin.setPosition(coordinates);
map.addOverlay(marker.pin);
-
- // Add event listeners
- var willSelect = true;
- var moveCount = 0;
- // The pin element used to be on `element_` but now it looks like it
- // moved to `element`. Maybe this was a change to OpenLayers.
- var pinEl = marker.pin.element_ || marker.pin.element;
-
- ['pointerdown', 'mousedown', 'touchstart'].forEach(function (type) {
- pinEl.addEventListener(type, function (e) {
- willSelect = true;
- moveCount = 0;
- passEventToTarget(e, olViewport);
+
+ // Add event listeners
+ var willSelect = true;
+ var moveCount = 0;
+ // The pin element used to be on `element_` but now it looks like it
+ // moved to `element`. Maybe this was a change to OpenLayers.
+ var pinEl = marker.pin.element_ || marker.pin.element;
+
+ ['pointerdown', 'mousedown', 'touchstart'].forEach(function (type) {
+ pinEl.addEventListener(type, function (e) {
+ willSelect = true;
+ moveCount = 0;
+ passEventToTarget(e, olViewport);
+ });
});
- });
-
- [
- 'pointermove',
- 'wheel',
- 'pointerdrag',
- 'pointerup',
- 'mousemove',
- 'touchmove'
- ].forEach(function (type) {
- pinEl.addEventListener(type, function (e) {
- passEventToTarget(e, olViewport);
+
+ [
+ 'pointermove',
+ 'wheel',
+ 'pointerdrag',
+ 'pointerup',
+ 'mousemove',
+ 'touchmove'
+ ].forEach(function (type) {
+ pinEl.addEventListener(type, function (e) {
+ passEventToTarget(e, olViewport);
+ });
});
- });
- ['pointermove', 'mousemove'].forEach(function (type) {
- pinEl.addEventListener(type, function (e) {
- moveCount++;
- if (moveCount > 2) {
- willSelect = false;
- }
+ ['pointermove', 'mousemove'].forEach(function (type) {
+ pinEl.addEventListener(type, function (e) {
+ moveCount++;
+ if (moveCount > 2) {
+ willSelect = false;
+ }
+ });
});
- });
- pinEl.addEventListener('click', function (e) {
- if (willSelect && !isSelected) {
- ui.naturalEvents.selectEvent(event.id, date);
- } else {
- passEventToTarget(e, olViewport);
- }
- });
- }
+ pinEl.addEventListener('click', function (e) {
+ if (willSelect && !isSelected) {
+ ui.naturalEvents.selectEvent(event.id, date);
+ } else {
+ passEventToTarget(e, olViewport);
+ }
+ });
+ }
- return marker;
+ return marker;
// empty objects (i.e., markers not within projection range) are filtered out
}).filter((marker) => !lodashIsEmpty(marker));
map.renderSync(); // Marker position will be off until this is called
diff --git a/web/js/natural-events/ui.js b/web/js/natural-events/ui.js
index 686ade2c6..3f14d8524 100644
--- a/web/js/natural-events/ui.js
+++ b/web/js/natural-events/ui.js
@@ -30,6 +30,9 @@ export default function naturalEventsUI (models, ui, config, request) {
var naturalEventsTrack = track(models, ui, config);
var init = function () {
+ console.log('MODELS', models);
+ console.log('UI', ui);
+ console.log('CONFIG', config);
map = ui.map.selected;
// Display loading information for user feedback on slow network
$('#wv-events').text('Loading...');
@@ -106,7 +109,7 @@ export default function naturalEventsUI (models, ui, config, request) {
self.filterEventList();
});
- if(model.active) {
+ if (model.active) {
// Remove previously stored markers
naturalEventMarkers.remove(self.markers);
// Store markers so the can be referenced later
@@ -115,21 +118,21 @@ export default function naturalEventsUI (models, ui, config, request) {
// check if selected event is in changed projection
if (self.selected.id) {
let findSelectedInProjection = lodashFind(self.markers, function(marker) {
- if(marker.pin) {
+ if (marker.pin) {
return marker.pin.id === self.selected.id;
} else {
return false;
}
- })
+ });
// remove selected event if not in changed projection
- if(!findSelectedInProjection) {
+ if (!findSelectedInProjection) {
self.deselectEvent();
self.filterEventList();
}
}
- }
+ }
models.proj.events.trigger('change');
- })
+ });
};
self.selectEvent = function (id, date) {
@@ -433,9 +436,9 @@ export default function naturalEventsUI (models, ui, config, request) {
});
// check for polygon geometries and/or perform projection coordinate transform
- var coordinates = (geometry.type === 'Polygon')
- ? olExtent.boundingExtent(olProj.transform(geometry.coordinates[0], 'EPSG:4326', models.proj.selected.crs))
- : olProj.transform(geometry.coordinates, 'EPSG:4326', models.proj.selected.crs);
+ var coordinates = (geometry.type === 'Polygon')
+ ? olExtent.boundingExtent(olProj.transform(geometry.coordinates[0], 'EPSG:4326', models.proj.selected.crs))
+ : olProj.transform(geometry.coordinates, 'EPSG:4326', models.proj.selected.crs);
return ui.map.animate.fly(coordinates, zoom);
};