diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index cf256d09..a548f3a5 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -549,6 +549,14 @@ L.U.Marker = L.Marker.extend({ this.setIcon(this.getIcon()) }, + highlight: function () { + L.DomUtil.addClass(this.options.icon.elements.main, 'umap-icon-active') + }, + + resetHighlight: function () { + L.DomUtil.removeClass(this.options.icon.elements.main, 'umap-icon-active') + }, + addInteractions: function () { L.U.FeatureMixin.addInteractions.call(this) this.on( @@ -562,10 +570,8 @@ L.U.Marker = L.Marker.extend({ if (!this.isReadOnly()) this.on('mouseover', this._enableDragging) this.on('mouseout', this._onMouseOut) this._popupHandlersAdded = true // prevent Leaflet from binding event on bindPopup - this.once('add', () => { - this.on('popupopen', this.options.icon.highlight, this.options.icon) - this.on('popupclose', this.options.icon.resetHighlight, this.options.icon) - }) + this.on('popupopen', this.highlight) + this.on('popupclose', this.resetHighlight) }, hasGeom: function () { diff --git a/umap/static/umap/js/umap.icon.js b/umap/static/umap/js/umap.icon.js index 5198cb26..87fb7e36 100644 --- a/umap/static/umap/js/umap.icon.js +++ b/umap/static/umap/js/umap.icon.js @@ -38,13 +38,6 @@ L.U.Icon = L.DivIcon.extend({ formatUrl: function (url, feature) { return L.Util.greedyTemplate(url || '', feature ? feature.extendedProperties() : {}) }, - - highlight: function () { - L.DomUtil.addClass(this.elements.main, 'umap-icon-active') - }, - resetHighlight: function () { - L.DomUtil.removeClass(this.elements.main, 'umap-icon-active') - }, }) L.U.Icon.Default = L.U.Icon.extend({