Skip to content

Commit

Permalink
apply/adapt set(Marker)Style PR IITC-CE#251 by johnd0e
Browse files Browse the repository at this point in the history
commit 6201837
  • Loading branch information
le-jeu committed Feb 15, 2021
1 parent 68130ce commit 008aac3
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions core/code/portal_marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},

Expand Down Expand Up @@ -133,31 +120,35 @@ 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();
}
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;
Expand Down

0 comments on commit 008aac3

Please sign in to comment.