Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add optional rotation paramater to event selection

ZachTRice6997d2d1a9d2
diff --git a/web/js/components/tour/modal-tour-in-progress.js b/web/js/components/tour/modal-tour-in-progress.js
index 1190f9ec3..a894d96b3 100644
--- a/web/js/components/tour/modal-tour-in-progress.js
+++ b/web/js/components/tour/modal-tour-in-progress.js
@@ -295,7 +295,7 @@ class ModalInProgress extends React.Component {
date = date.match(/\d{4}-\d{2}-\d{2}/) ? values[1] : null;
models.naturalEvents.events.trigger('activate');
if (id) {
- ui.naturalEvents.selectEvent(id, date);
+ ui.naturalEvents.selectEvent(id, date, rotation);
}
} else {
ui.sidebar.selectTab('layers');
@@ -311,13 +311,15 @@ class ModalInProgress extends React.Component {
let resolution = ui.map.selected.getView().getResolutionForExtent(extent);
var duration;
// Don't animate when projection changes
- if (prevState.p !== currentState.p) { duration = 0; } else { duration = 5000; }
- ui.map.selected.getView().animate({
- center: coordinates,
- duration: duration,
- resolution: resolution,
- rotation: rotation
- });
+ if (prevState.p !== currentState.p) { duration = 0; } else { duration = 4000; }
+ if (!currentState.e) {
+ ui.map.selected.getView().animate({
+ center: coordinates,
+ duration: duration,
+ resolution: resolution,
+ rotation: rotation
+ });
+ }
// To jump to extent & zoom (instead of animate):
// ui.map.selected.getView().fit(currentState.v, ui.map.selected.getSize());
diff --git a/web/js/map/animate.js b/web/js/map/animate.js
index 2c11164ef..d212a7f9d 100644
--- a/web/js/map/animate.js
+++ b/web/js/map/animate.js
@@ -11,7 +11,7 @@ export function mapAnimate(models, config, ui) {
* @param {integer} endZoom Ending Zoom Level
* @return {Promise} Promise that is fulfilled when animation completes
*/
- self.fly = function(endPoint, endZoom) {
+ self.fly = function (endPoint, endZoom, rotation) {
var view = ui.map.selected.getView();
var polarProjectionCheck = models.proj.selected.id !== 'geographic'; // boolean if current projection is polar
view.cancelAnimations();
@@ -24,8 +24,9 @@ export function mapAnimate(models, config, ui) {
var line = new OlGeomLineString([startPoint, endPoint]);
var distance = line.getLength(); // In map units, which is usually degrees
var distanceDuration = polarProjectionCheck ? distance / 50000 : distance; // limit large polar projection distances from coordinate transforms
- var duration = Math.floor(distanceDuration * 20 + 1000); // approx 6 seconds to go 360 degrees
- var animationPromise = function() {
+ var duration = Math.floor((distanceDuration * 20) + 1000); // approx 6 seconds to go 360 degrees
+ if (!rotation) rotation = 0;
+ var animationPromise = function () {
var args = Array.prototype.slice.call(arguments);
return new Promise(function(resolve, reject) {
args.push(function(complete) {
@@ -40,19 +41,16 @@ export function mapAnimate(models, config, ui) {
duration = duration < 1200 ? duration / 2 : duration;
// If the event is already visible, don't zoom out
return Promise.all([
- animationPromise({ center: endPoint, duration: duration }),
- animationPromise({ zoom: endZoom, duration: duration })
+ animationPromise({ center: endPoint, duration: duration, rotation: rotation }),
+ animationPromise({ zoom: endZoom, duration: duration, rotation: rotation })
]);
}
// Default animation zooms out to arc
return Promise.all([
- animationPromise({ center: endPoint, duration: duration }),
+ animationPromise({ center: endPoint, duration: duration, rotation: rotation }),
animationPromise(
- {
- zoom: getBestZoom(distance, startZoom, endZoom, view),
- duration: duration / 2
- },
- { zoom: endZoom, duration: duration / 2 }
+ { zoom: getBestZoom(distance, startZoom, endZoom, view), duration: duration / 2, rotation: rotation },
+ { zoom: endZoom, duration: duration / 2, rotation: rotation }
)
]);
};
diff --git a/web/js/natural-events/ui.js b/web/js/natural-events/ui.js
index 29a51e385..d8a967ab4 100644
--- a/web/js/natural-events/ui.js
+++ b/web/js/natural-events/ui.js
@@ -392,7 +392,7 @@ export default function naturalEventsUI(models, ui, config, request) {
});
};
- var zoomToEvent = function(event, date, isSameEventID) {
+ var zoomToEvent = function(event, date, isSameEventID, rotation) {
var category = event.categories[0].title;
var zoom = isSameEventID
? ui.map.selected.getView().getZoom()
@@ -429,7 +429,7 @@ export default function naturalEventsUI(models, ui, config, request) {
);
}
- return ui.map.animate.fly(coordinates, zoom);
+ return ui.map.animate.fly(coordinates, zoom, rotation);
};
init();
diff --git a/web/js/notifications/ui.js b/web/js/notifications/ui.js
index d5fcc4f4f..86da8c953 100644
--- a/web/js/notifications/ui.js
+++ b/web/js/notifications/ui.js
@@ -14,7 +14,7 @@ export function notificationsUi(models, config) {
self.notifyIconActive = false;
self.messageIconActive = false;
- url = config.features.alert.url;
+ url = config.features.notification.url;
alertBlockExists = false;
classes = {
alert: 'bolt',