Skip to content

Commit 5a7dfb8

Browse files
colors to locations
based on the source, including interactive layer that can filter out locations on the map
1 parent e5f2b18 commit 5a7dfb8

File tree

3 files changed

+123
-10
lines changed

3 files changed

+123
-10
lines changed

src/App.vue

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@
1313
v-for="item in legendItems"
1414
:key="item.bronId"
1515
class="legend-item"
16+
:class="{
17+
'legend-item--disabled': appStore.disabledCategories.has(
18+
item.bronId
19+
),
20+
}"
21+
@click="appStore.toggleCategory(item.bronId)"
1622
>
1723
<div
1824
class="legend-symbol"
19-
:style="{ borderColor: item.color }"
25+
:style="{
26+
borderColor: appStore.disabledCategories.has(item.bronId)
27+
? '#ccc'
28+
: item.color,
29+
opacity: appStore.disabledCategories.has(item.bronId) ? 0.5 : 1,
30+
}"
2031
></div>
2132
<span class="legend-text">{{ item.dataleverancier }}</span>
2233
</div>
@@ -79,6 +90,15 @@
7990
/>
8091
</td>
8192
</tr>
93+
<tr>
94+
<td>Dataleverancier</td>
95+
<td>
96+
{{
97+
locationsStore.activeLocation?.properties
98+
?.dataleverancier || "..."
99+
}}
100+
</td>
101+
</tr>
82102
</tbody>
83103
</v-table>
84104
</div>
@@ -134,7 +154,7 @@ function getColorForBronId(bronId) {
134154
1: "#008fc5",
135155
2: "#28a745",
136156
3: "#ffc107",
137-
4: "#dc3545",
157+
4: "#895129",
138158
};
139159
return colors[bronId] || "#6c757d"; // Gray fallback
140160
}
@@ -245,6 +265,22 @@ watch(
245265
display: flex;
246266
align-items: center;
247267
gap: 8px;
268+
cursor: pointer;
269+
padding: 4px;
270+
border-radius: 4px;
271+
transition: background-color 0.2s ease;
272+
}
273+
274+
.legend-item:hover {
275+
background-color: #f5f5f5;
276+
}
277+
278+
.legend-item--disabled {
279+
opacity: 0.5;
280+
}
281+
282+
.legend-item--disabled:hover {
283+
background-color: #f0f0f0;
248284
}
249285
250286
.legend-symbol {

src/components/LocationsLayer.vue

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,21 @@ watch(
5555
["==", ["get", "bron_id"], 3],
5656
"#ffc107",
5757
["==", ["get", "bron_id"], 4],
58-
"#dc3545",
58+
"#895129",
5959
"#6c757d",
6060
],
61+
"circle-opacity": [
62+
"case",
63+
["==", ["get", "bron_id"], 1],
64+
1,
65+
["==", ["get", "bron_id"], 2],
66+
1,
67+
["==", ["get", "bron_id"], 3],
68+
1,
69+
["==", ["get", "bron_id"], 4],
70+
1,
71+
1,
72+
],
6173
},
6274
});
6375
map.addSource("active-location", {
@@ -80,6 +92,12 @@ watch(
8092
map.on("click", "locations-layer", (e) => {
8193
const feature = e.features?.[0];
8294
if (feature) {
95+
const bronId = feature.properties?.bron_id;
96+
// Don't allow interaction if category is disabled
97+
if (appStore.disabledCategories.has(bronId)) {
98+
return;
99+
}
100+
83101
locationsStore.setActiveLocation(feature);
84102
appStore.expandPanel();
85103
@@ -97,10 +115,16 @@ watch(
97115
});
98116
99117
map.on("mouseenter", "locations-layer", (e) => {
100-
map.getCanvas().style.cursor = "pointer";
101-
102118
const feature = e.features?.[0];
103119
if (feature) {
120+
const hoverBronId = feature.properties?.bron_id;
121+
// Don't show hover if category is disabled
122+
if (appStore.disabledCategories.has(hoverBronId)) {
123+
map.getCanvas().style.cursor = "grab";
124+
return;
125+
}
126+
127+
map.getCanvas().style.cursor = "pointer";
104128
const coords = feature.geometry.coordinates.slice();
105129
const locatieId = feature.properties?.locatie_id || "Unknown";
106130
const peilfilterIds = feature.properties?.peilfilter_ids || "";
@@ -111,13 +135,8 @@ watch(
111135
: [];
112136
113137
// Build HTML content
114-
const bronId = feature.properties?.bron_id || "Unknown";
115-
const dataleverancier =
116-
feature.properties?.dataleverancier || "Unknown";
117138
118139
let htmlContent = `<div>Locatie ID: <strong>${locatieId}</strong></div>`;
119-
htmlContent += `<div>Bron ID: <strong>${bronId}</strong></div>`;
120-
htmlContent += `<div>Dataleverancier: <strong>${dataleverancier}</strong></div>`;
121140
122141
if (peilfilterList.length > 0) {
123142
const label =
@@ -150,6 +169,56 @@ watch(
150169
{ immediate: true }
151170
);
152171
172+
// Watch for disabled categories changes and update map layer
173+
watch(
174+
() => appStore.disabledCategories,
175+
(disabledCategories) => {
176+
const map = props.map;
177+
if (!map || !map.getLayer("locations-layer")) return;
178+
179+
// Update circle opacity based on disabled categories
180+
const opacityExpression = [
181+
"case",
182+
["==", ["get", "bron_id"], 1],
183+
disabledCategories.has(1) ? 0.3 : 1,
184+
["==", ["get", "bron_id"], 2],
185+
disabledCategories.has(2) ? 0.3 : 1,
186+
["==", ["get", "bron_id"], 3],
187+
disabledCategories.has(3) ? 0.3 : 1,
188+
["==", ["get", "bron_id"], 4],
189+
disabledCategories.has(4) ? 0.3 : 1,
190+
1,
191+
];
192+
193+
// Update stroke color to gray with transparency when disabled
194+
const strokeColorExpression = [
195+
"case",
196+
["==", ["get", "bron_id"], 1],
197+
disabledCategories.has(1) ? "rgba(153, 153, 153, 0.3)" : "#008fc5",
198+
["==", ["get", "bron_id"], 2],
199+
disabledCategories.has(2) ? "rgba(153, 153, 153, 0.3)" : "#28a745",
200+
["==", ["get", "bron_id"], 3],
201+
disabledCategories.has(3) ? "rgba(153, 153, 153, 0.3)" : "#ffc107",
202+
["==", ["get", "bron_id"], 4],
203+
disabledCategories.has(4) ? "rgba(153, 153, 153, 0.3)" : "#895129",
204+
"#6c757d",
205+
];
206+
207+
map.setPaintProperty(
208+
"locations-layer",
209+
"circle-opacity",
210+
opacityExpression
211+
);
212+
213+
map.setPaintProperty(
214+
"locations-layer",
215+
"circle-stroke-color",
216+
strokeColorExpression
217+
);
218+
},
219+
{ deep: true }
220+
);
221+
153222
watch(
154223
() => locationsStore.activeLocation,
155224
(activeLocation) => {

src/stores/app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { defineStore } from 'pinia'
44
export const useAppStore = defineStore('app', {
55
state: () => ({
66
panelIsCollapsed: true,
7+
disabledCategories: new Set(),
78
}),
89
actions: {
910
collapsePanel () {
@@ -15,5 +16,12 @@ export const useAppStore = defineStore('app', {
1516
togglePanel () {
1617
this.panelIsCollapsed = !this.panelIsCollapsed
1718
},
19+
toggleCategory (bronId) {
20+
if (this.disabledCategories.has(bronId)) {
21+
this.disabledCategories.delete(bronId)
22+
} else {
23+
this.disabledCategories.add(bronId)
24+
}
25+
},
1826
},
1927
})

0 commit comments

Comments
 (0)