-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathlayers.js
340 lines (319 loc) · 11.4 KB
/
layers.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
var bounds = new L.LatLngBounds(
new L.LatLng(84.67351257, -172.96875),
new L.LatLng(-54.36775852, 178.59375),
);
var map = L.map('map', {
maxBounds: bounds,
maxBoundsViscosity: 0.75,
}).setView([43, -83], 3);
map.options.minZoom = 3;
var baselayer1 = L.tileLayer(
'https://api.tiles.mapbox.com/v4/mapbox.emerald/{z}/{x}/{y}.png?access_token=pk.eyJ1Ijoic2FnYXJwcmVldDk3IiwiYSI6ImNqaXhlZjgwaDJtb3EzcW1zdDdwMzJkODcifQ.MA2YIv6VpGLLAo-QYUudTA',
{
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
},
).addTo(map);
var baselayer3 = L.tileLayer(
'https://api.tiles.mapbox.com/v4/mapbox.streets-basic/{z}/{x}/{y}.png?access_token=pk.eyJ1Ijoic2FnYXJwcmVldDk3IiwiYSI6ImNqaXhlZjgwaDJtb3EzcW1zdDdwMzJkODcifQ.MA2YIv6VpGLLAo-QYUudTA',
{
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
},
);
var baselayer2 = L.tileLayer(
'https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png',
{
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
},
);
var baselayer4 = L.tileLayer(
'https://api.tiles.mapbox.com/v4/mapbox.dark/{z}/{x}/{y}.png?access_token=pk.eyJ1Ijoic2FnYXJwcmVldDk3IiwiYSI6ImNqaXhlZjgwaDJtb3EzcW1zdDdwMzJkODcifQ.MA2YIv6VpGLLAo-QYUudTA',
{
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
},
);
var PLpeople = L.layerGroup.PLpeople();
var PurpleLayer = L.layerGroup.purpleLayer();
var ToxicRelease = L.layerGroup.toxicReleaseLayer();
var PFASTracker = L.layerGroup.pfasLayer();
var AQICNLayer = L.layerGroup.aqicnLayer();
var OSMLandfillMineQuarryLayer = L.layerGroup.osmLandfillMineQuarryLayer();
var PurpleAirMarkerLayer = L.layerGroup.layerCode('purpleairmarker');
var Fractracker = L.layerGroup.layerCode('fractracker');
var SkyTruth = L.layerGroup.layerCode('skytruth');
var OdorReport = L.layerGroup.layerCode('odorreport');
var MapKnitter = L.layerGroup.layerCode('mapknitter');
var OpenAqLayer = L.layerGroup.layerCode('openaq');
var LuftdatenLayer = L.layerGroup.layerCode('luftdaten');
var OpenSenseLayer = L.layerGroup.layerCode('opensense');
var OpenInfraMap_Power = L.tileLayer('https://tiles-{s}.openinframap.org/power/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://www.openinframap.org/about.html">About OpenInfraMap</a>',
}).on('tileerror', function() {
console.log('There was an error in fetching some tiles')
this.onError('Power', true);
});
var OpenInfraMap_Petroleum = L.tileLayer('https://tiles-{s}.openinframap.org/petroleum/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://www.openinframap.org/about.html">About OpenInfraMap</a>',
}).on('tileerror', function() {
this.onError('Petroleum', true);
});
var OpenInfraMap_Telecom = L.tileLayer('https://tiles-{s}.openinframap.org/telecoms/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://www.openinframap.org/about.html">About OpenInfraMap</a>',
}).on('tileerror', function() {
this.onError('Telecom', true);
});
var OpenInfraMap_Water = L.tileLayer('https://tiles-{s}.openinframap.org/water/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, <a href="http://www.openinframap.org/about.html">About OpenInfraMap</a>',
}).on('tileerror', function() {
this.onError('Water', true);
});
var Justicemap_income = L.tileLayer.provider('JusticeMap.income').on('tileerror', function() {
this.onError('income', true);
});
var JusticeMap_americanIndian = L.tileLayer.provider('JusticeMap.americanIndian').on('tileerror', function() {
this.onError('americanIndian', true);
});
var JusticeMap_asian = L.tileLayer.provider('JusticeMap.asian').on('tileerror', function() {
this.onError('asian', true);
});
var JusticeMap_black = L.tileLayer.provider('JusticeMap.black').on('tileerror', function() {
this.onError('black', true);
});
var JusticeMap_multi = L.tileLayer.provider('JusticeMap.multi').on('tileerror', function() {
this.onError('multi', true);
});
var JusticeMap_hispanic = L.tileLayer.provider('JusticeMap.hispanic').on('tileerror', function() {
this.onError('hispanic', true);
});
var JusticeMap_nonWhite = L.tileLayer.provider('JusticeMap.nonWhite').on('tileerror', function() {
this.onError('nonWhite', true);
});
var JusticeMap_white = L.tileLayer.provider('JusticeMap.white').on('tileerror', function() {
this.onError('white', true);
});
var JusticeMap_plurality = L.tileLayer.provider('JusticeMap.plurality').on('tileerror', function() {
this.onError('plurality', true);
});
var clouds = L.OWM.clouds({showLegend: true, opacity: 0.5}).on('tileerror', function() {
this.onError('Clouds', true);
});
var cloudscls = L.OWM.cloudsClassic({}).on('tileerror', function() {
this.onError('cloudsClassic', true);
});
var precipitation = L.OWM.precipitation({}).on('tileerror', function() {
this.onError('precipitation', true);
});
var precipitationcls = L.OWM.precipitationClassic({}).on('tileerror', function() {
this.onError('precipitationClassic', true);
});
var rain = L.OWM.rain({}).on('tileerror', function() {
this.onError('rain', true);
});
var raincls = L.OWM.rainClassic({}).on('tileerror', function() {
this.onError('rainClassic', true);
});
var snow = L.OWM.snow({}).on('tileerror', function() {
this.onError('snow', true);
});
var pressure = L.OWM.pressure({}).on('tileerror', function() {
this.onError('pressure', true);
});
var pressurecntr = L.OWM.pressureContour({}).on('tileerror', function() {
this.onError('pressureContour-zoomIn', true);
});
var temp = L.OWM.temperature({}).on('tileerror', function() {
this.onError('temp', true);
});
var wind = L.OWM.wind({}).on('tileerror', function() {
this.onError('wind', true);
});
var city = L.OWM.current({intervall: 15, minZoom: 3}).on('owmloadingend', function() {
this.onError('Cities-zoomIn', true);
});
var windrose = L.OWM.current({
intervall: 15,
minZoom: 3,
markerFunction: myWindroseMarker,
popup: false,
clusterSize: 50,
imageLoadingBgUrl: 'https://openweathermap.org/img/w0/iwind.png',
});
windrose.on('owmlayeradd', windroseAdded, windrose);
windrose.on('owmloadingend', function() {
this.onError('windrose-zoomIn', true);
});
var IndigenousLandsTerritories = L.layerGroup.indigenousLayers('Territories');
var IndigenousLandsLanguages = L.layerGroup.indigenousLayers('Languages');
var IndigenousLandsTreaties = L.layerGroup.indigenousLayers('Treaties');
var Unearthing = L.layerGroup.Unearthing();
var Wisconsin_NM = wisconsinLayer(map);
var FracTracker_mobile = L.geoJSON.fracTrackerMobile();
var EonetFiresLayer = L.geoJSON.eonetFiresLayer();
var baseMaps = {
'Standard': baselayer1,
// 'Grey-scale': baselayer2,
// 'Streets': baselayer3,
// 'Dark': baselayer4,
};
var overlayMaps = {
"PLpeople" : PLpeople,
'wisconsin': Wisconsin_NM,
'fractracker': Fractracker,
'fracTrackerMobile': FracTracker_mobile,
'purpleair': {
category: 'group',
layers: {
'purpleLayer': PurpleLayer,
'purpleairmarker': PurpleAirMarkerLayer,
}
},
'skytruth': SkyTruth,
'toxicReleaseLayer': ToxicRelease,
'odorreport': OdorReport,
'mapknitter': MapKnitter,
'openInfraMap': {
category: 'group',
layers: {
'Power': OpenInfraMap_Power,
'Telecom': OpenInfraMap_Telecom,
'Petroleum': OpenInfraMap_Petroleum,
'Water': OpenInfraMap_Water,
}
},
'indigenousLands': {
category: 'group',
layers: {
'Territories': IndigenousLandsTerritories,
'Languages': IndigenousLandsLanguages,
'Treaties': IndigenousLandsTreaties,
},
},
'justiceMap': {
category: 'group',
layers: {
'income': Justicemap_income,
'americanIndian': JusticeMap_americanIndian,
'asian': JusticeMap_asian,
'black': JusticeMap_black,
'multi': JusticeMap_multi,
'hispanic': JusticeMap_hispanic,
'nonWhite': JusticeMap_nonWhite,
'white': JusticeMap_white,
'plurality': JusticeMap_plurality,
},
},
'openWeatherMap': {
category: 'group',
layers: {
'Clouds': clouds,
'cloudsClassic': cloudscls,
'precipitation': precipitation,
'precipitationClassic': precipitationcls,
'rain': rain,
'rainClassic': raincls,
'snow': snow,
'pressure': pressure,
'pressureContour-zoomIn': pressurecntr,
'temp': temp,
'wind': wind,
'Cities-zoomIn': city,
'windrose-zoomIn': windrose,
},
},
'pfasLayer': PFASTracker,
'aqicnLayer': AQICNLayer,
'openaq': OpenAqLayer,
'luftdaten': LuftdatenLayer,
'opensense': OpenSenseLayer,
'osmLandfillMineQuarryLayer': OSMLandfillMineQuarryLayer,
'eonetFiresLayer': EonetFiresLayer,
'Unearthing': Unearthing
};
var allMapLayers = {
'Standard': baselayer1,
'Grey-scale': baselayer2,
'Streets': baselayer3,
'Dark': baselayer4,
"PLpeople" : PLpeople,
'wisconsin': Wisconsin_NM,
'fracTrackerMobile': FracTracker_mobile,
'purpleLayer': PurpleLayer,
'purpleairmarker': PurpleAirMarkerLayer,
'skytruth': SkyTruth,
'fractracker': Fractracker,
'pfasLayer': PFASTracker,
'toxicReleaseLayer': ToxicRelease,
'odorreport': OdorReport,
'mapknitter': MapKnitter,
'Power': OpenInfraMap_Power,
'Telecom': OpenInfraMap_Telecom,
'Petroleum': OpenInfraMap_Petroleum,
'Water': OpenInfraMap_Water,
'income': Justicemap_income,
'americanIndian': JusticeMap_americanIndian,
'asian': JusticeMap_asian,
'black': JusticeMap_black,
'multi': JusticeMap_multi,
'hispanic': JusticeMap_hispanic,
'nonWhite': JusticeMap_nonWhite,
'white': JusticeMap_white,
'plurality': JusticeMap_plurality,
'clouds': clouds,
'cloudsClassic': cloudscls,
'precipitation': precipitation,
'precipitationClassic': precipitationcls,
'rain': rain,
'rainClassic': raincls,
'snow': snow,
'pressure': pressure,
'pressureContour': pressurecntr,
'temperature': temp,
'wind': wind,
'city': city,
'windrose': windrose,
'Territories': IndigenousLandsTerritories,
'Languages': IndigenousLandsLanguages,
'Treaties': IndigenousLandsTreaties,
'aqicnLayer': AQICNLayer,
'openaq': OpenAqLayer,
'luftdaten': LuftdatenLayer,
'opensense': OpenSenseLayer,
'osmLandfillMineQuarryLayer': OSMLandfillMineQuarryLayer,
'eonetFiresLayer': EonetFiresLayer,
'Unearthing': Unearthing
};
// var oms = omsUtil(map, {
// keepSpiderfied: true,
// circleSpiralSwitchover: 0
// });
var hash = new L.FullHash(map, allMapLayers);
// var leafletControl = new L.control.layers(baseMaps, overlayMaps);
var leafletControl = new L.control.layersBrowser(baseMaps, overlayMaps);
leafletControl.addTo(map);
// only use this if you are using the layersBrowser
map.on('resize', function () {
leafletControl.setLayersBrowserSize(map);
});
leafletControl.setLayersBrowserSize(map);
var modeControl = new L.control.minimalMode(leafletControl);
modeControl.addTo(map);
var embedControl = new L.control.embed({
// hostname: 'your domain name goes here'
});
embedControl.addTo(map);
// Collapsible search control
new L.Control.GPlaceAutocomplete({
position: 'topleft',
collapsed_mode: true,
callback: function(place){
var loc = place.geometry.location;
map.setView( [loc.lat(), loc.lng()], 18);
}
}).addTo(map);