-
Notifications
You must be signed in to change notification settings - Fork 3
/
del.js
852 lines (755 loc) · 22.7 KB
/
del.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
//Mapbox Tiles
mapcenter = [77.18,28.58],
mapboxgl.accessToken =
"pk.eyJ1IjoiaGVzaGFtc2hhd3F5IiwiYSI6ImNrdnBvY2UwcTFkNDkzM3FmbTFhenM0M3MifQ.ZqIuL9khfbCyOF3DU_IH5w";
const map = new mapboxgl.Map({
container: "map",
style: "mapbox://styles/heshamshawqy/cl444p0qq000514mx2f30mtom",
center: mapcenter,
zoom: 12,
// bearing: -45,
});
map.on("load", () => {
// Disable default box zooming.
map.boxZoom.disable();
// disable map zoom when using scroll
map.scrollZoom.disable();
// disable map rotation using right click + drag
map.dragRotate.disable();
});
//01-INITIAL BUILDING MATERIAL RADAR CHART
//-------------------------------------------
map.on("load", () => {
var options = {
chart: {
id: "Mchart",
height: 350,
type: "radar",
foreColor: "#373d3f",
toolbar: {
show: false,
},
},
series: [
{
name: "Percentage %",
data: [0, 0, 0, 0, 0, 0],
},
],
plotOptions: {
radar: {
size: 90,
polygons: {
strokeColors: "#45c4b0",
strokeWidth: 2,
},
},
},
colors: ["#13678a"],
markers: {
size: 3,
colors: ["#56a356"],
strokeColor: "#56a356",
strokeWidth: 2,
},
fill: {
opacity: 0.7,
},
xaxis: {
categories: ["Concrete", "Brick", "Stone", "Glass", "Metal", "Wood"],
},
yaxis: {
min: 0,
max: 80,
tickAmount: 4,
},
};
var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();
});
//01-INITIAL MAP MATERIAL RADAR CHART
//-------------------------------------------
map.on("load", () => {
var options = {
chart: {
id: "Mapchart",
height: 400,
type: 'bar',
toolbar: {
show: false,
},
},
series: [
{
name: 'Percentage',
data: [0,0,0,0,0,0],
}
],
plotOptions: {
bar: {
horizontal: true,
}
},
colors: ['#56a356'],
dataLabels: {
style: {
colors: ['#012030']
},
formatter: function(val, opt) {
const goals =
opt.w.config.series[opt.seriesIndex].data[opt.dataPointIndex]
.goals
if (goals && goals.length) {
return `${val} / ${goals[0].value}`
}
return val
}
},
legend: {
show: true,
showForSingleSeries: true,
customLegendItems: ['Material Percentage %'],
markers: {
fillColors: ['#56a356']
}
},
xaxis: {
min: 0,
max: 40,
labels: {
},
categories: ['Concrete','Brick','Stone','Glass','Metal','Wood'],
tickPlacement: 'on'
},
yaxis: {
labels: {
rotate: 0,
style: {
colors: [],
fontSize: '9px',
fontFamily: 'Helvetica, Arial, sans-serif',
fontWeight: 400,
cssClass: 'apexcharts-xaxis-label',
},
},
}
};
var chart = new ApexCharts(document.querySelector("#mapchart"), options);
chart.render();
});
//01-INITIAL REGION MATERIAL RADAR CHART
//-------------------------------------------
map.on("load", () => {
var options = {
chart: {
id: "Regionchart",
height: 400,
type: 'bar',
toolbar: {
show: false,
},
},
series: [
{
name: 'Percentage',
data: [0,0,0,0,0,0],
}
],
plotOptions: {
bar: {
horizontal: true,
}
},
colors: ['#56a356'],
dataLabels: {
style: {
colors: ['#012030']
},
formatter: function(val, opt) {
const goals =
opt.w.config.series[opt.seriesIndex].data[opt.dataPointIndex]
.goals
if (goals && goals.length) {
return `${val} / ${goals[0].value}`
}
return val
}
},
legend: {
show: true,
showForSingleSeries: true,
customLegendItems: ['Material Percentage %'],
markers: {
fillColors: ['#56a356']
}
},
xaxis: {
min: 0,
max: 40,
labels: {
},
categories: ['Concrete','Brick','Stone','Glass','Metal','Wood'],
tickPlacement: 'on'
},
yaxis: {
labels: {
rotate: 0,
style: {
colors: [],
fontSize: '9px',
fontFamily: 'Helvetica, Arial, sans-serif',
fontWeight: 400,
cssClass: 'apexcharts-xaxis-label',
},
},
}
};
var chart = new ApexCharts(document.querySelector("#Regionchart"), options);
chart.render();
});
//02-GEOJSON LAYERS - DIFFERENT SCENARIOS
//-------------------------------------------
map.on("load", () => {
// place map labels on top of layers
//----------------------------------------------------
const layers = map.getStyle().layers;
let firstSymbolId;
for (const layer of layers) {
if (layer.type === "symbol") {
firstSymbolId = layer.id;
break;
}
}
// adding buildings layer
//----------------------------------------------------
map.addSource("combined", {
type: "geojson",
// Use any Mapbox-hosted tileset using its tileset id.
// Learn more about where to find a tileset id:
// https://docs.mapbox.com/help/glossary/tileset-id/
// https://github.com/mapnik/node-mapnik/issues/707#issuecomment-408474671
data: "library/geodata/DEL_data.geojson",
generateId: true,
// mode: "no-cors",
// url: "mapbox://heshamshawqy.a8akk9ft",
});
map.addLayer(
// how to fix duplicated buildings id
//https://github.com/mapbox/mapbox-gl-js/issues/7038
{
id: "b-id",
type: "fill-extrusion",
source: "combined",
// "source-layer": "combined",
// color based on a feature https://stackoverflow.com/questions/63713703/mapbox-gl-js-coloring-individual-features-in-large-geojson
layout: {},
paint: {
"fill-extrusion-color": [
"case",
["boolean", ["feature-state", "hover"], false],
"#96d96a",
"#525d70",
],
"fill-extrusion-height": ["get", "height"],
"fill-extrusion-opacity": 0.85,
},
},
firstSymbolId
);
document.getElementById("defaultOpen").addEventListener("click", () => {
//remove layers if they exist
if (map.getLayer("2dBuildings-highlighted")) {
map.removeLayer("2dBuildings-highlighted");
}
if (map.getSource("BCN")) {
map.removeSource("BCN");
}
hoveredStateId = null;
//fly to the original camera parameters
map.getCanvas().style.cursor = "grab";
map.flyTo({
center: mapcenter,
zoom: 12,
pitch: 0,
bearing: 0,
});
});
// MAPPING SCENARIOS
// 01-MAP
//----------------------------------------------------
document.getElementById("mapfilter").addEventListener("click", () => {
//unique features https://stackoverflow.com/questions/57632629/how-to-get-unique-feature-properties-from-geojson-source-in-mapbox-gl-js
// query features from the geojson file
//remove layers if they exist
if (map.getLayer("2dBuildings-highlighted")) {
map.removeLayer("2dBuildings-highlighted");
}
if (map.getSource("BCN")) {
map.removeSource("BCN");
}
hoveredStateId = null;
//fly to the original camera parameters
map.getCanvas().style.cursor = "grab";
map.flyTo({
center: mapcenter,
zoom: 12,
pitch: 0,
bearing: 0,
});
// disable map zoom when using scroll
map.scrollZoom.enable();
// disable map rotation using right click + drag
map.dragRotate.disable();
//unique features function to remove duplicated mapbox features
function getUniqueFeatures(array, comparatorProperty) {
var existingFeatureKeys = {};
var uniqueFeatures = array.filter(function (el) {
if (existingFeatureKeys[el.properties[comparatorProperty]]) {
return false;
} else {
existingFeatureKeys[el.properties[comparatorProperty]] = true;
return true;
}
});
return uniqueFeatures;
}
//using query source features to extract visible properties
var Mfeatures = map.querySourceFeatures("combined", {
sourceLayer: "b-id",
});
// console.log(Mfeatures);
var uniqueFeatures = getUniqueFeatures(Mfeatures, "id");
// console.log(uniqueFeatures);
let i = 0;
let Mconcrete = [];
let Mbrick = [];
let Mstone = [];
let Mglass = [];
let Mmetal = [];
let Mwood = [];
let Mid = [];
let len = uniqueFeatures.length;
for (; i < len; i++) {
Mconcrete.push(uniqueFeatures[i].properties.concrete);
Mbrick.push(uniqueFeatures[i].properties.bricks);
Mstone.push(uniqueFeatures[i].properties.stone);
Mglass.push(uniqueFeatures[i].properties.glass);
Mmetal.push(uniqueFeatures[i].properties.metal);
Mwood.push(uniqueFeatures[i].properties.wood);
Mid.push(uniqueFeatures[i].properties.id);
}
let count = (Mconcrete.filter( Boolean )).length;
const Tconcrete = (Mconcrete.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tbrick = (Mbrick.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tstone = (Mstone.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tglass = (Mglass.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tmetal = (Mmetal.filter( Boolean )).reduce((a, b) => a + b, 0);
const Twood = (Mwood.filter( Boolean )).reduce((a, b) => a + b, 0);
const Pconcrete = Math.round(((Tconcrete/len)*100)*100)/100;
const Pbrick = Math.round(((Tbrick/len)*100)*100)/100;
const Pstone = Math.round(((Tstone/len)*100)*100)/100;
const Pglass = Math.round(((Tglass/len)*100)*100)/100;
const Pmetal = Math.round(((Tmetal/len)*100)*100)/100;
const Pwood = Math.round(((Twood/len)*100)*100)/100;
console.log(Pconcrete)
console.log(Pbrick)
console.log(Pstone)
console.log(Pglass)
console.log(Pmetal)
console.log(Pwood)
ApexCharts.exec("Mapchart", "updateSeries", [
{
data: [Pconcrete, Pbrick, Pstone, Pglass, Pmetal, Pwood],
},
]);
document.getElementById("Bcount").innerHTML = "Buildings Count = "+69961;
});
// 02-REGION
//----------------------------------------------------
document.getElementById("regionfilter").addEventListener("click", () => {
hoveredStateId = null;
map.boxZoom.disable ();
//fly to the original camera parameters
map.getCanvas().style.cursor = "grab";
map.flyTo({
center: mapcenter,
zoom: 16,
pitch: 0,
bearing: 0,
});
// disable map zoom when using scroll
map.scrollZoom.enable();
// disable map rotation using right click + drag
map.dragRotate.disable();
// window.alert(
// "Hold Shift and drag the map to query features for multiple buildings"
// );
map.setPaintProperty("b-id", "fill-extrusion-color", [
"case",
["boolean", ["feature-state", "hover"], false],
"#96d96a",
"#525d70",
],
);
// map.setLayoutProperty("b-id", "visibility", "none");
const canvas = map.getCanvasContainer();
// Variable to hold the starting xy coordinates
// when `mousedown` occured.
let start;
// Variable to hold the current xy coordinates
// when `mousemove` or `mouseup` occurs.
let current;
// Variable for the draw box element.
let box;
map.addSource("BCN", {
type: "geojson",
// Use any Mapbox-hosted tileset using its tileset id.
// Learn more about where to find a tileset id:
// https://docs.mapbox.com/help/glossary/tileset-id/
// https://github.com/mapnik/node-mapnik/issues/707#issuecomment-408474671
data: "library/geodata/DEL_data.geojson",
generateId: true,
// mode: "no-cors",
// url: "mapbox://heshamshawqy.a8akk9ft",
});
map.addLayer(
{
id: "2dBuildings-highlighted",
type: "fill",
source: "BCN",
paint: {
"fill-color": "#96d96a",
// 'fill-opacity': 0.75
},
filter: ["in", "id", ""],
},
firstSymbolId
); // Place polygon under these labels.
// Set `true` to dispatch the event before other functions
// call it. This is necessary for disabling the default map
// dragging behaviour.
canvas.addEventListener("mousedown", mouseDown, true);
// Return the xy coordinates of the mouse position
function mousePos(e) {
const rect = canvas.getBoundingClientRect();
return new mapboxgl.Point(
e.clientX - rect.left - canvas.clientLeft,
e.clientY - rect.top - canvas.clientTop
);
}
function mouseDown(e) {
// Continue the rest of the function if the shiftkey is pressed.
if (!(e.shiftKey && e.button === 0)) return;
// Disable default drag zooming when the shift key is held down.
map.dragPan.disable();
// Call functions for the following events
document.addEventListener("mousemove", onMouseMove);
document.addEventListener("mouseup", onMouseUp);
document.addEventListener("keydown", onKeyDown);
// Capture the first xy coordinates
start = mousePos(e);
}
function onMouseMove(e) {
// Capture the ongoing xy coordinates
current = mousePos(e);
// Append the box element if it doesnt exist
if (!box) {
box = document.createElement("div");
box.classList.add("boxdraw");
canvas.appendChild(box);
}
const minX = Math.min(start.x, current.x),
maxX = Math.max(start.x, current.x),
minY = Math.min(start.y, current.y),
maxY = Math.max(start.y, current.y);
// Adjust width and xy position of the box element ongoing
const pos = `translate(${minX}px, ${minY}px)`;
box.style.transform = pos;
box.style.width = maxX - minX + "px";
box.style.height = maxY - minY + "px";
}
function onMouseUp(e) {
// Capture xy coordinates
finish([start, mousePos(e)]);
}
function onKeyDown(e) {
// If the ESC key is pressed
if (e.keyCode === 27) finish();
}
function finish(bbox) {
// Remove these events now that finish has been called.
document.removeEventListener("mousemove", onMouseMove);
document.removeEventListener("keydown", onKeyDown);
document.removeEventListener("mouseup", onMouseUp);
if (box) {
box.parentNode.removeChild(box);
box = null;
}
// If bbox exists. use this value as the argument for `queryRenderedFeatures`
if (bbox) {
const features = map.queryRenderedFeatures(bbox, {
layers: ["b-id"],
});
if (features.length >= 5000) {
return window.alert("Select a smaller number of features");
}
// Run through the selected features and set a filter
// to match features with unique FIPS codes to activate
// the `counties-highlighted` layer.
const fips = features.map((feature) => feature.properties.id);
console.log(fips);
map.setFilter("2dBuildings-highlighted", ["in", "id", ...fips]);
//unique features function to remove duplicated mapbox features
// console.log(Mfeatures);
// console.log(uniqueFeatures);
const Mconcrete = features.map((feature) => feature.properties.concrete);
const Mbrick = features.map((feature) => feature.properties.bricks);
const Mstone = features.map((feature) => feature.properties.stone);
const Mglass = features.map((feature) => feature.properties.glass);
const Mmetal = features.map((feature) => feature.properties.metal);
const Mwood = features.map((feature) => feature.properties.wood);
console.log(Mconcrete)
let Rcount = fips.length;
const Tconcrete = (Mconcrete.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tbrick = (Mbrick.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tstone = (Mstone.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tglass = (Mglass.filter( Boolean )).reduce((a, b) => a + b, 0);
const Tmetal = (Mmetal.filter( Boolean )).reduce((a, b) => a + b, 0);
const Twood = (Mwood.filter( Boolean )).reduce((a, b) => a + b, 0);
const Pconcrete = Math.round(((Tconcrete/Rcount)*100)*100)/100;
const Pbrick = Math.round(((Tbrick/Rcount)*100)*100)/100;
const Pstone = Math.round(((Tstone/Rcount)*100)*100)/100;
const Pglass = Math.round(((Tglass/Rcount)*100)*100)/100;
const Pmetal = Math.round(((Tmetal/Rcount)*100)*100)/100;
const Pwood = Math.round(((Twood/Rcount)*100)*100)/100;
console.log(Pconcrete)
console.log(Pbrick)
console.log(Pstone)
console.log(Pglass)
console.log(Pmetal)
console.log(Pwood)
ApexCharts.exec("Regionchart", "updateSeries", [
{
data: [Pconcrete, Pbrick, Pstone, Pglass, Pmetal, Pwood],
},
]);
document.getElementById("BRcount").innerHTML = "Buildings Count = "+Rcount;
}
map.dragPan.enable();
}
// map.on("mousemove", (e) => {
// const features = map.queryRenderedFeatures(e.point, {
// layers: ["2dBuildings-highlighted"],
// });
// // Change the cursor style as a UI indicator.
// map.getCanvas().style.cursor = features.length ? "pointer" : "";
// });
});
// 03-BUILDING
//----------------------------------------------------
document.getElementById("buildingfilter").addEventListener("click", () => {
map.flyTo({
center: mapcenter,
zoom: 17,
pitch: 50,
bearing: 0,
});
map.boxZoom.disable();
// disable map zoom when using scroll
map.scrollZoom.enable();
// disable map rotation using right click + drag
map.dragRotate.enable();
let hoveredFeatureId = null;
map.setPaintProperty("b-id", "fill-extrusion-color", [
"case",
["boolean", ["feature-state", "hover"], false],
"#96d96a",
"#525d70",
],
);
if (map.getLayer("2dBuildings-highlighted")) {
map.removeLayer("2dBuildings-highlighted");
}
if (map.getSource("BCN")) {
map.removeSource("BCN");
}
// When the user moves their mouse over the state-fill layer, we'll update the
// feature state for the feature under the mouse .
map.on("mousemove", "b-id", (e) => {
if (e.features.length > 0) {
if (hoveredFeatureId !== null) {
map.setFeatureState(
{
source: "combined",
// sourceLayer: "combined",
id: hoveredFeatureId,
},
{ hover: false }
);
}
hoveredFeatureId = e.features[0].id;
map.setFeatureState(
{
source: "combined",
// sourceLayer: "combined",
id: hoveredFeatureId,
},
{ hover: true }
);
}
});
// When the mouse leaves the state-fill layer, update the feature state of the
// previously hovered feature.
map.on("mouseleave", "b-id", () => {
if (hoveredFeatureId !== null) {
map.setFeatureState(
{
source: "combined",
// sourceLayer: "combined",
id: hoveredFeatureId,
},
{ hover: false }
);
}
});
// Change the cursor to a pointer when the mouse is over the places layer.
map.on("mouseenter", "b-id", () => {
map.getCanvas().style.cursor = "pointer";
});
// Change it back to a pointer when it leaves.
map.on("mouseleave", "b-id", () => {
map.getCanvas().style.cursor = "";
});
// show feature on click
map.on("click", "b-id", (e) => {
document.getElementById("type").innerHTML =
"<p class='info-box'><b>Building Typology</b></p>" +
e.features[0].properties.currentUse;
document.getElementById("age").innerHTML =
"<p class='info-box'><b>Building Age</b></p>" +
e.features[0].properties.bld_age;
document.getElementById("simg").innerHTML =
"<img src=" +
e.features[0].properties.documentLi +
" class='f-img' ></img>";
var m_concrete = Math.round(e.features[0].properties.concrete * 100);
//-----
var m_brick = Math.round(e.features[0].properties.bricks * 100);
//-----
var m_stone = Math.round(e.features[0].properties.stone * 100);
//-----
var m_glass = Math.round(e.features[0].properties.glass * 100);
//-----
var m_metal = Math.round(e.features[0].properties.metal * 100);
//-----
var m_wood = Math.round(e.features[0].properties.wood * 100);
//-----
ApexCharts.exec("Mchart", "updateSeries", [
{
data: [m_concrete, m_brick, m_stone, m_glass, m_metal, m_wood],
},
]);
});
hoveredStateId = null;
});
});
//03-MATERIAL LAYERS
//https://docs.mapbox.com/mapbox-gl-js/example/color-switcher/
//-------------------------------------------
map.on("load", () => {
document.getElementById("l-none").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"case",
["boolean", ["feature-state", "hover"], false],
"#96d96a",
"#525d70",
]);
});
document.getElementById("l-age").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"interpolate-hcl",
["linear"],
["get", "bld_age"],
1900,
"#044348",
1930,
"#8dc0c5",
2015,
"#e1f7fa",
]);
});
document.getElementById("l-concrete").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"interpolate-hcl",
["linear"],
["get", "concrete"],
0.05,
"#91c8f9",
0.75,
"#0c3c68",
]);
});
document.getElementById("l-brick").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"interpolate-hcl",
["linear"],
["get", "bricks"],
0.05,
"#d67de3",
0.75,
"#3a0342",
]);
});
document.getElementById("l-stone").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"interpolate-hcl",
["linear"],
["get", "stone"],
0.05,
"#cdacac",
0.3,
"#3e1b1b",
]);
});
document.getElementById("l-glass").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"interpolate-hcl",
["linear"],
["get", "glass"],
0.05,
"#ebb992",
0.4,
"#6d2100",
]);
});
document.getElementById("l-metal").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"interpolate-hcl",
["linear"],
["get", "metal"],
0.01,
"#cadfa9",
0.15,
"#3d4600",
]);
});
document.getElementById("l-wood").addEventListener("click", () => {
map.setPaintProperty("b-id", "fill-extrusion-color", [
"interpolate-hcl",
["linear"],
["get", "wood"],
0.03,
"#ffeb43",
0.25,
"#a15f00",
]);
});
});
//04-Mapbox Controls
//-------------------------------------------
// const nav = new mapboxgl.NavigationControl({
// visualizePitch: true,
// showZoom: true,
// showCompass: true,
// });
// map.addControl(nav, "top-left");