From fe20489950aa8f5453a17344228ac0ed9f9b9708 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 24 Aug 2023 16:56:37 +0200 Subject: [PATCH] hack to prevent minimap to change map center at load --- umap/static/umap/js/umap.controls.js | 9 ++++++++- umap/static/umap/js/umap.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 9d5a7a6c..f0f39da9 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1365,12 +1365,19 @@ L.U.SearchControl = L.Control.extend({ }, }) -L.Control.MiniMap.include({ +L.U.MiniMap = L.Control.MiniMap.extend({ initialize: function (layer, options) { L.Util.setOptions(this, options) this._layer = this._cloneLayer(layer) }, + onAdd: function (map) { + L.Control.MiniMap.prototype.onAdd.call(this, map); + // Prevent the MiniMap to send a moveend at init + this._mainMapMoving = true + return this._container + }, + onMainMapBaseLayerChange: function (e) { const layer = this._cloneLayer(e.layer) if (this._miniMap.hasLayer(this._layer)) { diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 282b97da..c6429cc0 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -357,7 +357,7 @@ L.U.Map.include({ if (this.options.miniMap && !this.options.noControl) { this.whenReady(function () { if (this.selected_tilelayer) { - this._controls.miniMap = new L.Control.MiniMap(this.selected_tilelayer).addTo( + this._controls.miniMap = new L.U.MiniMap(this.selected_tilelayer).addTo( this ) this._controls.miniMap._miniMap.invalidateSize()