Skip to content

Commit e24f68c

Browse files
committed
added Paint prop for tiles
1 parent 5e4181d commit e24f68c

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

src/lib/components/data-vis/map/Map.svelte

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@
8383
onidle,
8484
geoSource = "file",
8585
tileSource = "http://localhost:8080/{z}/{x}/{y}.pbf",
86+
paintObject,
8687
}: {
8788
data: object[];
89+
paintObject?: object;
8890
customPalette?: object[];
8991
cooperativeGestures?: boolean;
9092
standardControls?: boolean;
@@ -426,37 +428,7 @@
426428
tiles={[tileSource]}
427429
>
428430
<FillLayer
429-
paint={{
430-
"fill-color": [
431-
"match",
432-
[
433-
"to-number",
434-
["get", "Index of Multiple Deprivation (IMD) Decile"],
435-
],
436-
1,
437-
"#ffffcc",
438-
2,
439-
"#ffffcc",
440-
3,
441-
"#a1dab4",
442-
4,
443-
"#a1dab4",
444-
5,
445-
"#41b6c4",
446-
6,
447-
"#41b6c4",
448-
7,
449-
"#2c7fb8",
450-
8,
451-
"#2c7fb8",
452-
9,
453-
"#253494",
454-
10,
455-
"#253494",
456-
/* default */ "rgba(0,0,0,0)",
457-
],
458-
"fill-opacity": 0.4,
459-
}}
431+
paint={paintObject}
460432
sourceLayer={"LSOA"}
461433
onclick={interactive
462434
? (e) => {

src/wrappers/components/data-vis/map/MapWrapper.svelte

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,43 @@
449449
value: "http://localhost:8080/{z}/{x}/{y}.pbf",
450450
visible: { name: "geoSource", value: "tiles" },
451451
},
452+
{
453+
name: "paintObject",
454+
isProp: true,
455+
description: "Paint object to pass in colouring",
456+
category: "Data",
457+
value: {
458+
"fill-color": [
459+
"match",
460+
[
461+
"to-number",
462+
["get", "Index of Multiple Deprivation (IMD) Decile"],
463+
],
464+
1,
465+
"#ffffcc",
466+
2,
467+
"#ffffcc",
468+
3,
469+
"#a1dab4",
470+
4,
471+
"#a1dab4",
472+
5,
473+
"#41b6c4",
474+
6,
475+
"#41b6c4",
476+
7,
477+
"#2c7fb8",
478+
8,
479+
"#2c7fb8",
480+
9,
481+
"#253494",
482+
10,
483+
"#253494",
484+
/* default */ "rgba(0,0,0,0)",
485+
],
486+
"fill-opacity": 0.4,
487+
},
488+
},
452489
{ name: "addData", isProp: true, category: "Data", value: true },
453490
{
454491
name: "year",

0 commit comments

Comments
 (0)