From 228aa0ebc617e65dfd2ac26ccabad1677af1c87d Mon Sep 17 00:00:00 2001 From: LeJeu <64744459+le-jeu@users.noreply.github.com> Date: Sun, 14 Feb 2021 19:30:57 +0100 Subject: [PATCH] set marker style once --- core/code/portal_marker.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/core/code/portal_marker.js b/core/code/portal_marker.js index 8485b6ae6..1f66703d1 100644 --- a/core/code/portal_marker.js +++ b/core/code/portal_marker.js @@ -25,6 +25,19 @@ function handler_portal_contextmenu (e) { } } +var CompatPortalMarker = L.Class.extend({ + initialize: function (portal) { + this.options = portal.options; + this.style = {}; + }, + setStyle: function (style) { + this.style = style; + }, + getStyle: function () { + return this.style; + } +}) + var PortalMarker = L.CircleMarker.extend({ options: {}, @@ -127,9 +140,8 @@ var PortalMarker = L.CircleMarker.extend({ }, reset: function (selected) { var styleOptions = this._style(); - this.setStyle(styleOptions); - this.highlight(); + L.Util.extend(styleOptions, this.highlight()) if (selected === false) this._selected = false; @@ -137,10 +149,14 @@ var PortalMarker = L.CircleMarker.extend({ this._selected = this._selected || selected; if (this._selected) - this.setStyle ({color: COLOR_SELECTED_PORTAL}); + L.Util.extend(styleOptions, {color: COLOR_SELECTED_PORTAL}); + + this.setOptions(styleOptions); }, highlight: function () { - highlightPortal(this); + var compatPortal = new CompatPortalMarker(this); + var style = highlightPortal(compatPortal); + return style || compatPortal.getStyle(); }, _style: function () { var dashArray = null;