Extracted portal marker into a separate function
This allows creation of plugins providing alternate portal marker styles and shapes (for third party plugin development). And it makes sense anyway :)
This commit is contained in:
parent
e63bf82e5a
commit
5b3220cb98
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// MAP DATA //////////////////////////////////////////////////////////
|
// MAP DATA //////////////////////////////////////////////////////////
|
||||||
// these functions handle how and which entities are displayed on the
|
// these functions handle how and which entities are displayed on the
|
||||||
// map. They also keep them up to date, unless interrupted by user
|
// map. They also keep them up to date, unless interrupted by user
|
||||||
@ -500,6 +499,32 @@ window.removeByGuid = function(guid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Separation of marker style setting from the renderPortal method
|
||||||
|
// Having this as a separate function allows subsituting alternate marker rendering (for plugins)
|
||||||
|
window.getMarker = function(ent, portalLevel, latlng, team) {
|
||||||
|
var lvWeight = Math.max(2, Math.floor(portalLevel) / 1.5);
|
||||||
|
var lvRadius = Math.floor(portalLevel) + 4;
|
||||||
|
if(team === window.TEAM_NONE) {
|
||||||
|
lvRadius = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = L.circleMarker(latlng, {
|
||||||
|
radius: lvRadius + (L.Browser.mobile ? PORTAL_RADIUS_ENLARGE_MOBILE : 0),
|
||||||
|
color: ent[0] === selectedPortal ? COLOR_SELECTED_PORTAL : COLORS[team],
|
||||||
|
opacity: 1,
|
||||||
|
weight: lvWeight,
|
||||||
|
fillColor: COLORS[team],
|
||||||
|
fillOpacity: 0.5,
|
||||||
|
clickable: true,
|
||||||
|
level: portalLevel,
|
||||||
|
team: team,
|
||||||
|
ent: ent,
|
||||||
|
details: ent[2],
|
||||||
|
guid: ent[0]});
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// renders a portal on the map from the given entity
|
// renders a portal on the map from the given entity
|
||||||
window.renderPortal = function(ent) {
|
window.renderPortal = function(ent) {
|
||||||
@ -548,25 +573,7 @@ window.renderPortal = function(ent) {
|
|||||||
// pre-loads player names for high zoom levels
|
// pre-loads player names for high zoom levels
|
||||||
loadPlayerNamesForPortal(ent[2]);
|
loadPlayerNamesForPortal(ent[2]);
|
||||||
|
|
||||||
var lvWeight = Math.max(2, Math.floor(portalLevel) / 1.5);
|
var p = getMarker(ent, portalLevel, latlng, team);
|
||||||
var lvRadius = Math.floor(portalLevel) + 4;
|
|
||||||
if(team === window.TEAM_NONE) {
|
|
||||||
lvRadius = 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
var p = L.circleMarker(latlng, {
|
|
||||||
radius: lvRadius + (L.Browser.mobile ? PORTAL_RADIUS_ENLARGE_MOBILE : 0),
|
|
||||||
color: ent[0] === selectedPortal ? COLOR_SELECTED_PORTAL : COLORS[team],
|
|
||||||
opacity: 1,
|
|
||||||
weight: lvWeight,
|
|
||||||
fillColor: COLORS[team],
|
|
||||||
fillOpacity: 0.5,
|
|
||||||
clickable: true,
|
|
||||||
level: portalLevel,
|
|
||||||
team: team,
|
|
||||||
ent: ent,
|
|
||||||
details: ent[2],
|
|
||||||
guid: ent[0]});
|
|
||||||
|
|
||||||
p.on('remove', function() {
|
p.on('remove', function() {
|
||||||
var portalGuid = this.options.guid
|
var portalGuid = this.options.guid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user