-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathhighlight-high-level.js
56 lines (49 loc) · 1.32 KB
/
highlight-high-level.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @author jonatkins
// @name Highlight high level portals
// @category Highlighter
// @version 0.2.3
// @description Use the portal fill color to denote high level portals: Purple L8, Red L7, Orange L6
/* exported setup, changelog --eslint */
/* global L -- eslint */
var changelog = [
{
version: '0.2.3',
changes: ['Refactoring: fix eslint'],
},
{
version: '0.2.2',
changes: ['Version upgrade due to a change in the wrapper: plugin icons are now vectorized'],
},
{
version: '0.2.1',
changes: ['Version upgrade due to a change in the wrapper: added plugin icon'],
},
];
// use own namespace for plugin
var highLevel = {};
window.plugin.highlightHighLevel = highLevel;
highLevel.styles = {
common: {
fillOpacity: 0.7,
},
level6: {
fillColor: 'orange',
},
level7: {
fillColor: 'red',
},
level8: {
fillColor: 'magenta',
},
};
function highlightHighLevel(data) {
var portal_level = data.portal.options.data.level;
if (portal_level === undefined) return; // continue on 0..8
var newStyle = L.extend({}, highLevel.styles.common, highLevel.styles['level' + portal_level]);
if (newStyle.fillColor) {
data.portal.setStyle(newStyle);
}
}
function setup() {
window.addPortalHighlighter('Higher Level Portals', highlightHighLevel);
}