Interactive interface for browsing global, full-resolution satellite imagery
modify map zoom button func to prevent under/over zooming and fix some animation jerky easing issues, debounce zoom change, constrain resolution zoom with mouse wheel
Ed Platof328ffd5a45e
diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 9eeb23f16..6d075c65e 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -798,6 +798,7 @@ export default function mapui(models, config, store, ui) {}),new OlInteractionMouseWheelZoom({duration: animationDuration,+ constrainResolution: true,}),new OlInteractionDragZoom({duration: animationDuration,@@ -909,6 +910,20 @@ export default function mapui(models, config, store, ui) {});$zoomIn.mousemove((e) => e.stopPropagation());+ /*+ * Debounce for below onZoomChange function+ *+ * @funct debouncedZoomChange+ * @static+ *+ * @returns {void}+ *+ */+ const debouncedZoomChange = () => {+ onZoomChange();+ self.events.trigger('movestart');+ };+/** Sets zoom buttons as active or inactive based* on the zoom level@@ -933,11 +948,7 @@ export default function mapui(models, config, store, ui) {$zoomOut.button('enable');}};-- map.getView().on('change:resolution', () => {- onZoomChange();- self.events.trigger('movestart');- });+ map.getView().on('change:resolution', lodashDebounce(debouncedZoomChange, 30));onZoomChange();}diff --git a/web/js/map/util.js b/web/js/map/util.jsindex 76fab331b..76d8a78b1 100644--- a/web/js/map/util.js+++ b/web/js/map/util.js@@ -21,12 +21,38 @@ export function mapUtilZoomAction(map, amount, duration, center) {const centerPoint = center || undefined;const view = map.getView();const zoom = view.getZoom();+ const minZoom = view.getMinZoom();+ const maxZoom = view.getMaxZoom();++ let newZoom = zoom + amount;+ const newZoomBelowMin = newZoom < minZoom;+ const newZoomExceedsMax = newZoom > maxZoom;++ // if newZoom is animating, it may not be an integer+ // and will require revising to within min/max zoom constraints+ if (zoom < maxZoom && newZoomExceedsMax) {+ newZoom = maxZoom;+ } else if (zoom > minZoom && newZoomBelowMin) {+ newZoom = minZoom;+ } else if (newZoomExceedsMax || newZoomBelowMin) {+ return;+ }++ const isAnimating = view.getAnimating();view.animate({- zoom: zoom + amount,- duration: zoomDuration,+ zoom: newZoom,+ duration: isAnimating ? 0 : zoomDuration,center: centerPoint,});}++/**+ * getActiveLayerGroup+ * @param {Object} map+ * @param {string} layerGroupString+ *+ * @return {Object} group+ */export function getActiveLayerGroup(map, layerGroupString) {let group = null;const array = map.getLayers().getArray();@@ -39,6 +65,7 @@ export function getActiveLayerGroup(map, layerGroupString) {}return group;}+/*** Create x/y/z vectortile requester url* @param {Date} date@@ -63,6 +90,7 @@ export function createVectorUrl(date, layerName, tileMatrixSet) {];return `?${params.join('&')}`;}+/**** @param {Object} def