From ca127c8c3cc9e91655efc739b7c17adb7babfda1 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 29 Nov 2024 18:32:14 +0100 Subject: [PATCH] fix: do not fail when navigating with popup arrows in cluster mode - make sure we have correct `this` in callback - do not call anymatePan if icon is not added to map (because clusterized) --- umap/static/umap/js/modules/rendering/popup.js | 3 ++- umap/static/umap/js/modules/rendering/template.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/modules/rendering/popup.js b/umap/static/umap/js/modules/rendering/popup.js index e460e118..3baf2793 100644 --- a/umap/static/umap/js/modules/rendering/popup.js +++ b/umap/static/umap/js/modules/rendering/popup.js @@ -44,7 +44,8 @@ const Popup = BasePopup.extend({ DomEvent.on(el, 'load', () => { this._updateLayout() this._updatePosition() - this._adjustPan() + // Do not call when feature is in cluster. + if (this._map) this._adjustPan() }) }, }) diff --git a/umap/static/umap/js/modules/rendering/template.js b/umap/static/umap/js/modules/rendering/template.js index 7f62acfa..e0738a39 100644 --- a/umap/static/umap/js/modules/rendering/template.js +++ b/umap/static/umap/js/modules/rendering/template.js @@ -60,7 +60,7 @@ class PopupTemplate { feature: nextFeature.properties.name || translate('next'), }) DomEvent.on(next, 'click', () => { - nextFeature.zoomTo({ callback: nextFeature.view }) + nextFeature.zoomTo({ callback: (event) => nextFeature.view(event) }) }) } if (previousFeature) { @@ -68,7 +68,7 @@ class PopupTemplate { feature: previousFeature.properties.name || translate('previous'), }) DomEvent.on(previous, 'click', () => { - previousFeature.zoomTo({ callback: previousFeature.view }) + previousFeature.zoomTo({ callback: (event) => previousFeature.view(event) }) }) } DomEvent.on(zoom, 'click', () => feature.zoomTo())