Skip to content

Commit 26826d5

Browse files
committed
fixed indigenousLands on one line constructor
1 parent 6ed8248 commit 26826d5

File tree

4 files changed

+101
-50
lines changed

4 files changed

+101
-50
lines changed

dist/LeafletEnvironmentalLayers.js

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26468,30 +26468,44 @@ return jQuery;
2646826468
},{}],7:[function(require,module,exports){
2646926469
const layers = require("./info.json");
2647026470

26471-
let layers0 = [],layers1 = [],layers2 = [],layers3 = [],layers4 = [],layers5 = [],layers6 = [];
26472-
26471+
let layers0 = [],
26472+
layers1 = [],
26473+
layers2 = [],
26474+
layers3 = [],
26475+
layers4 = [],
26476+
layers5 = [],
26477+
layers6 = [],
26478+
layers7 = [];
26479+
26480+
// This section deals with different layers in customized ways.
26481+
// I think we could restructure to detect some layers which are groups
26482+
// containing multiple other layers, or most other layouts, automatically.
26483+
26484+
// handle simpler layers which have a layer_group defined in info.json
2647326485
for (let key in layers) {
2647426486
if (layers.hasOwnProperty(key)) {
2647526487
let layer = layers[key];
26476-
if(layer.layer_group == 0){
26488+
if (layer.layer_group == 0) {
2647726489
layers0.push(key)
26478-
}
26479-
if(layer.layer_group == 1){
26490+
} else if (layer.layer_group == 1) {
2648026491
layers1.push(key)
26481-
}
26482-
if(layer.layer_group == 3){
26492+
} else if (layer.layer_group == 3) {
2648326493
layers3.push(key)
26484-
}
26485-
if(layer.layer_group == 6){
26494+
} else if (layer.layer_group == 6) {
2648626495
layers6.push(key)
2648726496
}
2648826497
}
2648926498
}
26499+
26500+
// handle special cases later with a special key
2649026501
layers0.push("purpleLayer")
2649126502
layers1.push("purpleairmarker")
26503+
26504+
// handle grouped layers which have a layers property (an array of sublayers)
2649226505
layers2 = layers.openInfraMap.layers;
2649326506
layers4 = layers.justiceMap.layers;
2649426507
layers5 = layers.openWeatherMap.layers;
26508+
layers7 = layers.indigenousLands.layers;
2649526509

2649626510
L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2649726511

@@ -26511,6 +26525,7 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2651126525
layers4: layers4,
2651226526
layers5: layers5,
2651326527
layers6: layers6,
26528+
layers7: layers7
2651426529

2651526530
},
2651626531

@@ -26520,7 +26535,17 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2652026535

2652126536
this.options.addLayersToMap = !!param.include ? param.addLayersToMap : false;
2652226537

26523-
param.all = [...this.options.layers0, ...this.options.layers1, ...this.options.layers2, ...this.options.layers3, ...this.options.layers4, ...this.options.layers5, ...this.options.layers6];
26538+
param.all = [
26539+
...this.options.layers0,
26540+
...this.options.layers1,
26541+
...this.options.layers2,
26542+
...this.options.layers3,
26543+
...this.options.layers4,
26544+
...this.options.layers5,
26545+
...this.options.layers6,
26546+
...this.options.layers7
26547+
];
26548+
2652426549
if (!param.include || !param.include.length) {
2652526550
param.include = param.all;
2652626551
}
@@ -26532,6 +26557,7 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2653226557

2653326558
this.options.layers = param;
2653426559

26560+
// define layers from OpenInfraMap for later use
2653526561
this._OpenInfraMap_Power = L.tileLayer('https://tiles-{s}.openinframap.org/power/{z}/{x}/{y}.png', {
2653626562
maxZoom: 18,
2653726563
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://www.openinframap.org/about.html">About OpenInfraMap</a>',
@@ -26600,8 +26626,7 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2660026626
default:
2660126627
this.groupedOverlayMaps[layer] = this.overlayMaps[layer];
2660226628
}
26603-
}
26604-
else if (this.options.layers2.includes(layer)) {
26629+
} else if (this.options.layers2.includes(layer)) {
2660526630
if(!this.groupedOverlayMaps.OpenInfraMap) {
2660626631
this.groupedOverlayMaps.OpenInfraMap = { category: 'group', layers: {} };
2660726632
}
@@ -26624,21 +26649,18 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2662426649
this.groupedOverlayMaps.OpenInfraMap.layers[layer] = this.overlayMaps[layer];
2662526650
break;
2662626651
}
26627-
}
26628-
else if (this.options.layers3.includes(layer)) {
26652+
} else if (this.options.layers3.includes(layer)) {
2662926653
this.overlayMaps[layer] = window[layer + 'Layer'](map);
2663026654
this.groupedOverlayMaps[layer] = this.overlayMaps[layer];
26631-
}
26632-
else if (this.options.layers4.includes(layer)) {
26655+
} else if (this.options.layers4.includes(layer)) {
2663326656
if(!this.groupedOverlayMaps.Justicemap) {
2663426657
this.groupedOverlayMaps.Justicemap = { category: 'group', layers: {} };
2663526658
}
2663626659
this.overlayMaps[layer] = window['L']['tileLayer']['provider']('JusticeMap.'+layer).on('tileerror', function() {
2663726660
this.onError(layer, true);
2663826661
});
2663926662
this.groupedOverlayMaps.Justicemap.layers[layer] = this.overlayMaps[layer];
26640-
}
26641-
else if (this.options.layers5.includes(layer)) {
26663+
} else if (this.options.layers5.includes(layer)) {
2664226664
if(!this.groupedOverlayMaps['Open Weather Map']) {
2664326665
this.groupedOverlayMaps['Open Weather Map'] = { category: 'group', layers: {} };
2664426666
}
@@ -26661,15 +26683,19 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2666126683
this.onError(layer, true);
2666226684
});
2666326685
}
26664-
2666526686
this.groupedOverlayMaps['Open Weather Map'].layers[layer] = this.overlayMaps[layer];
26666-
}
26667-
else if (this.options.layers6.includes(layer)) {
26687+
} else if (this.options.layers6.includes(layer)) {
2666826688
this.overlayMaps[layer] = window['L']['geoJSON'][layer]();
2666926689
this.groupedOverlayMaps[layer] = this.overlayMaps[layer];
26670-
}
26671-
else {
26672-
console.log('Incorrect Layer Name');
26690+
} else if (this.options.layers7.includes(layer)) {
26691+
if(!this.groupedOverlayMaps.indigenousLands) {
26692+
this.groupedOverlayMaps.indigenousLands = { category: 'group', layers: {} };
26693+
}
26694+
26695+
this.overlayMaps[layer] = L.layerGroup.indigenousLayers(layer);
26696+
this.groupedOverlayMaps.indigenousLands.layers[layer] = this.overlayMaps[layer];
26697+
} else {
26698+
console.log('Incorrect Layer Name: ', layer);
2667326699
}
2667426700
}
2667526701

@@ -26732,7 +26758,6 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2673226758
},
2673326759
);
2673426760

26735-
2673626761
L.LayerGroup.EnvironmentalLayers = function(options) {
2673726762
return new L.LayerGroup.environmentalLayers(options);
2673826763
};

example/oneLinerCodeExample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
var LEL = L.LayerGroup.EnvironmentalLayers({
7575
// simpleLayerControl: true,
7676
addLayersToMap: true,
77-
include: ['skytruth', 'odorreport', 'asian', 'wind', 'city', 'eonetFiresLayer', 'Unearthing', 'PLpeople'],
77+
//include: ['Territories', 'skytruth', 'odorreport', 'asian', 'wind', 'city', 'eonetFiresLayer', 'Unearthing', 'PLpeople'],
7878
// exclude: ['mapknitter', 'clouds'],
7979
// display: ['eonetFiresLayer'],
8080
hash: true,

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AllLayers.js

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
const layers = require("./info.json");
22

3-
let layers0 = [],layers1 = [],layers2 = [],layers3 = [],layers4 = [],layers5 = [],layers6 = [];
3+
let layers0 = [],
4+
layers1 = [],
5+
layers2 = [],
6+
layers3 = [],
7+
layers4 = [],
8+
layers5 = [],
9+
layers6 = [],
10+
layers7 = [];
411

12+
// This section deals with different layers in customized ways.
13+
// I think we could restructure to detect some layers which are groups
14+
// containing multiple other layers, or most other layouts, automatically.
15+
16+
// handle simpler layers which have a layer_group defined in info.json
517
for (let key in layers) {
618
if (layers.hasOwnProperty(key)) {
719
let layer = layers[key];
8-
if(layer.layer_group == 0){
20+
if (layer.layer_group == 0) {
921
layers0.push(key)
10-
}
11-
if(layer.layer_group == 1){
22+
} else if (layer.layer_group == 1) {
1223
layers1.push(key)
13-
}
14-
if(layer.layer_group == 3){
24+
} else if (layer.layer_group == 3) {
1525
layers3.push(key)
16-
}
17-
if(layer.layer_group == 6){
26+
} else if (layer.layer_group == 6) {
1827
layers6.push(key)
1928
}
2029
}
2130
}
31+
32+
// handle special cases later with a special key
2233
layers0.push("purpleLayer")
2334
layers1.push("purpleairmarker")
35+
36+
// handle grouped layers which have a layers property (an array of sublayers)
2437
layers2 = layers.openInfraMap.layers;
2538
layers4 = layers.justiceMap.layers;
2639
layers5 = layers.openWeatherMap.layers;
40+
layers7 = layers.indigenousLands.layers;
2741

2842
L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
2943

@@ -43,6 +57,7 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
4357
layers4: layers4,
4458
layers5: layers5,
4559
layers6: layers6,
60+
layers7: layers7
4661

4762
},
4863

@@ -52,7 +67,17 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
5267

5368
this.options.addLayersToMap = !!param.include ? param.addLayersToMap : false;
5469

55-
param.all = [...this.options.layers0, ...this.options.layers1, ...this.options.layers2, ...this.options.layers3, ...this.options.layers4, ...this.options.layers5, ...this.options.layers6];
70+
param.all = [
71+
...this.options.layers0,
72+
...this.options.layers1,
73+
...this.options.layers2,
74+
...this.options.layers3,
75+
...this.options.layers4,
76+
...this.options.layers5,
77+
...this.options.layers6,
78+
...this.options.layers7
79+
];
80+
5681
if (!param.include || !param.include.length) {
5782
param.include = param.all;
5883
}
@@ -64,6 +89,7 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
6489

6590
this.options.layers = param;
6691

92+
// define layers from OpenInfraMap for later use
6793
this._OpenInfraMap_Power = L.tileLayer('https://tiles-{s}.openinframap.org/power/{z}/{x}/{y}.png', {
6894
maxZoom: 18,
6995
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://www.openinframap.org/about.html">About OpenInfraMap</a>',
@@ -132,8 +158,7 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
132158
default:
133159
this.groupedOverlayMaps[layer] = this.overlayMaps[layer];
134160
}
135-
}
136-
else if (this.options.layers2.includes(layer)) {
161+
} else if (this.options.layers2.includes(layer)) {
137162
if(!this.groupedOverlayMaps.OpenInfraMap) {
138163
this.groupedOverlayMaps.OpenInfraMap = { category: 'group', layers: {} };
139164
}
@@ -156,21 +181,18 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
156181
this.groupedOverlayMaps.OpenInfraMap.layers[layer] = this.overlayMaps[layer];
157182
break;
158183
}
159-
}
160-
else if (this.options.layers3.includes(layer)) {
184+
} else if (this.options.layers3.includes(layer)) {
161185
this.overlayMaps[layer] = window[layer + 'Layer'](map);
162186
this.groupedOverlayMaps[layer] = this.overlayMaps[layer];
163-
}
164-
else if (this.options.layers4.includes(layer)) {
187+
} else if (this.options.layers4.includes(layer)) {
165188
if(!this.groupedOverlayMaps.Justicemap) {
166189
this.groupedOverlayMaps.Justicemap = { category: 'group', layers: {} };
167190
}
168191
this.overlayMaps[layer] = window['L']['tileLayer']['provider']('JusticeMap.'+layer).on('tileerror', function() {
169192
this.onError(layer, true);
170193
});
171194
this.groupedOverlayMaps.Justicemap.layers[layer] = this.overlayMaps[layer];
172-
}
173-
else if (this.options.layers5.includes(layer)) {
195+
} else if (this.options.layers5.includes(layer)) {
174196
if(!this.groupedOverlayMaps['Open Weather Map']) {
175197
this.groupedOverlayMaps['Open Weather Map'] = { category: 'group', layers: {} };
176198
}
@@ -193,15 +215,19 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
193215
this.onError(layer, true);
194216
});
195217
}
196-
197218
this.groupedOverlayMaps['Open Weather Map'].layers[layer] = this.overlayMaps[layer];
198-
}
199-
else if (this.options.layers6.includes(layer)) {
219+
} else if (this.options.layers6.includes(layer)) {
200220
this.overlayMaps[layer] = window['L']['geoJSON'][layer]();
201221
this.groupedOverlayMaps[layer] = this.overlayMaps[layer];
202-
}
203-
else {
204-
console.log('Incorrect Layer Name');
222+
} else if (this.options.layers7.includes(layer)) {
223+
if(!this.groupedOverlayMaps.indigenousLands) {
224+
this.groupedOverlayMaps.indigenousLands = { category: 'group', layers: {} };
225+
}
226+
227+
this.overlayMaps[layer] = L.layerGroup.indigenousLayers(layer);
228+
this.groupedOverlayMaps.indigenousLands.layers[layer] = this.overlayMaps[layer];
229+
} else {
230+
console.log('Incorrect Layer Name: ', layer);
205231
}
206232
}
207233

@@ -264,7 +290,6 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
264290
},
265291
);
266292

267-
268293
L.LayerGroup.EnvironmentalLayers = function(options) {
269294
return new L.LayerGroup.environmentalLayers(options);
270295
};

0 commit comments

Comments
 (0)