From 571154e4f3804a9c17e0dee2f7cf74efe7733e44 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 15 May 2024 15:17:50 +0200 Subject: [PATCH] fix: error when clicking on the geolocate button fix #1812 --- umap/static/umap/js/umap.controls.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index e019fb7b..df984d90 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1031,8 +1031,17 @@ U.Locate = L.Control.Locate.extend({ _activate: function () { this._map = this.map L.Control.Locate.prototype._activate.call(this) - this._map = null }, + + remove: function () { + // Prevent to call remove if the control is not really added to the map + // This occurs because we do create the control and call its activate + // method before adding the control button itself to the map, in the + // case where the map defaultView is set to "location" + if (!this._container || !this._container.parentNode) return + return L.Control.Locate.prototype.remove.call(this) + }, + }) U.Search = L.PhotonSearch.extend({