Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Annoted notes of the problem.

Stephan Wlodarczyk17a0d00cec87
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 935bfe16e..aac5aa33d 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -257,6 +257,7 @@ export function mapui(models, config, store, ui) {
} else if (!models.map.extent && projId === 'geographic') {
extent = getLeadingExtent(config.pageLoadTime);
callback = () => {
+ console.log('callback return');
const map = self.selected;
const view = map.getView();
const extent = view.calculateExtent(map.getSize());
@@ -265,18 +266,34 @@ export function mapui(models, config, store, ui) {
}
if (extent) {
const view = map.getView();
- const mapRotation = view.getRotation();
- // Fit the layer extent to the given size of the map
+ const mapRotation = (Math.abs(view.getRotation()) * (180 / Math.PI)).toFixed(4);
+
+ // This is where the funny business happens
view.fit(extent, {
constrainResolution: false,
callback,
});
- // Correct the zoom level if map was rotated
+ // view.getZoom() doing this after fit yields a floating zoom level (i.e. -0.2223, 1.8845, etc.)
+
+ // console.log(view.getZoom())
+
+ /** Originally, I was trying to a find a way to either round up or down the value,
+ or truncate it completely based on the rotation value. When you rotate the map, the zoom level will
+ either go up or down; it will not be a whole number. */
+
+ // let zoom = Math.trunc(view.getZoom());
+ // let zoom = Math.floor(view.getZoom());
+ // let zoom = Math.ceil(view.getZoom());
+
if (mapRotation) {
- let zoom = Math.round(view.getZoom());
- if (zoom >= 0) zoom += 1;
+ const zoom = Math.ceil(view.getZoom());
+ /** Run the app, and rotate the map using the rotational buttons, reload the page, view should be restored.
+ Now rotate the map using the alt + mouse and get a decimal rotation value, (i.e. 137.448), infinte zoom
+ should take place. Not all decimal values will cause it to happen. */
+ // if (mapRotation >= 29 && mapRotation <= 60) zoom += 1;
+ // else if (mapRotation >= 114 && mapRotation < 160) zoom += 1;
view.setZoom(zoom);
}
}