Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-2607 Granule zoom issues on mobile (#4108)

Tom Cariello26a228d0a1cc
diff --git a/package-lock.json b/package-lock.json
index 095933142..adc0d079e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -147,7 +147,7 @@
"yargs": "^17.6.2"
},
"engines": {
- "node": ">= 16"
+ "node": ">= 18"
}
},
"node_modules/@ampproject/remapping": {
diff --git a/web/js/map/granule/util.js b/web/js/map/granule/util.js
index 1285f9a38..1dbcf19a4 100644
--- a/web/js/map/granule/util.js
+++ b/web/js/map/granule/util.js
@@ -11,6 +11,7 @@ import OlGeomLineString from 'ol/geom/LineString';
import { transform } from 'ol/proj';
import { Polygon as OlGeomPolygon } from 'ol/geom';
import * as OlExtent from 'ol/extent';
+import debounce from 'lodash/debounce';
import util from '../../util/util';
import { CRS } from '../../modules/map/constants';
@@ -364,7 +365,7 @@ export const areCoordinatesAndPolygonExtentValid = (points, coords, maxExtent) =
* @param {*} map
* @returns
*/
-export const granuleFootprint = (map) => {
+export const granuleFootprint = (map, initialIsMobile) => {
let currentGranule = {};
let vectorLayer = {};
const vectorSource = new OlVectorSource({
@@ -408,6 +409,8 @@ export const granuleFootprint = (map) => {
map.addLayer(vectorLayer);
};
+ const debouncedDrawFootprint = debounce(drawFootprint, 850);
+
const addFootprint = (points, date) => {
if (currentGranule[date]) {
return;
@@ -420,12 +423,20 @@ export const granuleFootprint = (map) => {
removeFootprint();
}
currentGranule[date] = true;
- drawFootprint(points, date);
+ if (initialIsMobile) {
+ debouncedDrawFootprint(points, date);
+ } else {
+ drawFootprint(points, date, 'addFootprint');
+ }
};
const updateFootprint = (points, date) => {
removeFootprint();
- drawFootprint(points, date);
+ if (initialIsMobile) {
+ debouncedDrawFootprint(points, date);
+ } else {
+ drawFootprint(points, date, 'addFootprint');
+ }
};
return {
diff --git a/web/js/mapUI/components/create-map/createMap.js b/web/js/mapUI/components/create-map/createMap.js
index 4185ae306..bbad6e2f3 100644
--- a/web/js/mapUI/components/create-map/createMap.js
+++ b/web/js/mapUI/components/create-map/createMap.js
@@ -54,7 +54,7 @@ function CreateMap(props) {
updateRotation,
} = props;
- const { projections } = config;
+ const { initialIsMobile, projections } = config;
let granuleFootprintsObj = {};
const animationDuration = 250;
const doubleClickZoom = new OlInteractionDoubleClickZoom({
@@ -219,7 +219,7 @@ function CreateMap(props) {
});
map.on('rendercomplete', onRenderComplete);
- granuleFootprintsObj = { ...granuleFootprintsObj, [proj.crs]: granuleFootprint(map) };
+ granuleFootprintsObj = { ...granuleFootprintsObj, [proj.crs]: granuleFootprint(map, initialIsMobile) };
window.addEventListener('resize', () => {
map.getView().changed();