Skip to content

Commit e88ca13

Browse files
Merge pull request #149 from communitiesuk/feature/map-legend|OIT-477
Feature/map legend|oit 477
2 parents 2276005 + a44a118 commit e88ca13

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
borderColor = "#003300",
108108
labelSourceLayer = "place",
109109
externalData = null,
110+
showLegend = false,
110111
}: {
111112
data: object[];
112113
paintObject?: object;
@@ -149,6 +150,7 @@
149150
setCustomPalette?: boolean;
150151
customBreaks?: number[];
151152
interactive?: boolean;
153+
showLegend: boolean;
152154
onload?: (map: maplibregl.Map) => void;
153155
onerror?: (error: Partial<ErrorEvent>) => void;
154156
onclick?: (e: maplibregl.MapMouseEvent) => void;
@@ -572,15 +574,16 @@
572574
{/if}
573575
</MapLibre>
574576
</div>
575-
576-
<div class="legend">
577-
{#each legendItems as item}
578-
<div class="legend-item">
579-
<div class="legend-color" style="background-color: {item.color};"></div>
580-
<span>{item.label}</span>
581-
</div>
582-
{/each}
583-
</div>
577+
{#if showLegend}
578+
<div class="legend">
579+
{#each legendItems as item}
580+
<div class="legend-item">
581+
<div class="legend-color" style="background-color: {item.color};"></div>
582+
<span>{item.label}</span>
583+
</div>
584+
{/each}
585+
</div>
586+
{/if}
584587

585588
<style>
586589
:global(.maplibregl-ctrl-group button.reset-button) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@
291291
value: 400,
292292
description: "Set height of map",
293293
},
294+
{
295+
name: "showLegend",
296+
category: "Styling",
297+
isProp: true,
298+
value: false,
299+
description: "Show the map Legend",
300+
},
294301
{
295302
name: "styleSheet",
296303
isProp: true,

0 commit comments

Comments
 (0)