From 008aac3ebf4b3db86a49531236d87e9a58ce9109 Mon Sep 17 00:00:00 2001 From: LeJeu <64744459+le-jeu@users.noreply.github.com> Date: Mon, 15 Feb 2021 19:13:31 +0100 Subject: [PATCH] apply/adapt set(Marker)Style PR #251 by johnd0e commit 6201837d94c87345d80086503b3623127276adca --- core/code/portal_marker.js | 43 +++++++++++++++----------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/core/code/portal_marker.js b/core/code/portal_marker.js index 300ddf7a8..8c54a89f8 100644 --- a/core/code/portal_marker.js +++ b/core/code/portal_marker.js @@ -25,19 +25,6 @@ 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; - } -}) - L.PortalMarker = L.CircleMarker.extend({ options: {}, @@ -133,6 +120,22 @@ L.PortalMarker = L.CircleMarker.extend({ hasFullDetails: function () { return !!this._details.mods }, + setStyle: function (style) { // stub for highlighters + L.Util.setOptions(this, style); + return this; + }, + setMarkerStyle: function (style) { + var styleOptions = L.Util.extend(this._style(), style); + L.Util.setOptions(this, styleOptions); + + L.Util.setOptions(this, highlightPortal(this)); + + var selected = L.extend( + { radius: this.options.radius }, + this._selected && { color: COLOR_SELECTED_PORTAL } + ); + return L.CircleMarker.prototype.setStyle.call(this, selected); + }, select: function (selected) { if (selected) { this.renderDetails(); @@ -140,24 +143,12 @@ L.PortalMarker = L.CircleMarker.extend({ return this.reset(selected); }, reset: function (selected) { - var styleOptions = this._style(); - - L.Util.extend(styleOptions, this.highlight()) - if (selected === false) this._selected = false; else this._selected = this._selected || selected; - if (this._selected) - L.Util.extend(styleOptions, {color: COLOR_SELECTED_PORTAL}); - - this.setStyle(styleOptions); - }, - highlight: function () { - var compatPortal = new CompatPortalMarker(this); - var style = highlightPortal(compatPortal); - return style || compatPortal.getStyle(); + return this.setMarkerStyle(); }, _style: function () { var dashArray = null;