-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f36f3b
commit 93c562a
Showing
5 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<script lang="ts"> | ||
import type { MapGeoJSONFeature } from "maplibre-gl"; | ||
import { | ||
hoveredToggle, | ||
overwriteLineLayer, | ||
overwritePolygonLayer, | ||
overwriteSource, | ||
} from "../../maplibre_helpers"; | ||
import { map } from "../../stores"; | ||
import { | ||
ColorLegend, | ||
ExternalLink, | ||
HelpButton, | ||
InteractiveLayer, | ||
} from "../common"; | ||
import { Checkbox } from "../govuk"; | ||
import { colors } from "./colors"; | ||
let name = "combined_authorities"; | ||
let color = colors.combined_authorities; | ||
let outlineLayer = `${name}-outline`; | ||
overwriteSource($map, name, `https://atip.uk/layers/v1/${name}.geojson`); | ||
overwritePolygonLayer($map, { | ||
id: name, | ||
source: name, | ||
color, | ||
opacity: hoveredToggle(0.5, 0.1), | ||
}); | ||
overwriteLineLayer($map, { | ||
id: outlineLayer, | ||
source: name, | ||
color, | ||
width: 2.5, | ||
}); | ||
let show = false; | ||
// InteractiveLayer manages the polygon layer, but we also need to control the outline | ||
$: { | ||
if ($map.getLayer(outlineLayer)) { | ||
$map.setLayoutProperty( | ||
outlineLayer, | ||
"visibility", | ||
show ? "visible" : "none" | ||
); | ||
} | ||
} | ||
function tooltip(feature: MapGeoJSONFeature): string { | ||
return `<p>${feature.properties.name}</p>`; | ||
} | ||
function onClick(e: CustomEvent<MapGeoJSONFeature>) { | ||
window.open( | ||
`https://www.ons.gov.uk/visualisations/areas/${e.detail.properties.CAUTH22CD}`, | ||
"_blank" | ||
); | ||
} | ||
</script> | ||
|
||
<Checkbox id={name} bind:checked={show}> | ||
<ColorLegend {color} /> | ||
Combined authorities | ||
<span slot="right"> | ||
<HelpButton> | ||
<p> | ||
Data from <ExternalLink | ||
href="https://geoportal.statistics.gov.uk/datasets/ons::combined-authorities-december-2022-boundaries-en-buc/explore" | ||
> | ||
ONS Geography | ||
</ExternalLink>, as of December 2022. | ||
</p> | ||
<p> | ||
License: <ExternalLink | ||
href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" | ||
> | ||
Open Government License | ||
</ExternalLink>. Contains OS data © Crown copyright and database | ||
right 2023. | ||
</p> | ||
</HelpButton> | ||
</span> | ||
</Checkbox> | ||
|
||
<InteractiveLayer layer={name} {tooltip} {show} on:click={onClick} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<script lang="ts"> | ||
import type { MapGeoJSONFeature } from "maplibre-gl"; | ||
import { | ||
hoveredToggle, | ||
overwriteLineLayer, | ||
overwritePolygonLayer, | ||
overwriteSource, | ||
} from "../../maplibre_helpers"; | ||
import { map } from "../../stores"; | ||
import { | ||
ColorLegend, | ||
ExternalLink, | ||
HelpButton, | ||
InteractiveLayer, | ||
} from "../common"; | ||
import { Checkbox } from "../govuk"; | ||
import { colors } from "./colors"; | ||
let name = "local_authority_districts"; | ||
let color = colors.local_authority_districts; | ||
let outlineLayer = `${name}-outline`; | ||
overwriteSource($map, name, `https://atip.uk/layers/v1/${name}.geojson`); | ||
overwritePolygonLayer($map, { | ||
id: name, | ||
source: name, | ||
color, | ||
opacity: hoveredToggle(0.5, 0.1), | ||
}); | ||
overwriteLineLayer($map, { | ||
id: outlineLayer, | ||
source: name, | ||
color, | ||
width: 2.5, | ||
}); | ||
let show = false; | ||
// InteractiveLayer manages the polygon layer, but we also need to control the outline | ||
$: { | ||
if ($map.getLayer(outlineLayer)) { | ||
$map.setLayoutProperty( | ||
outlineLayer, | ||
"visibility", | ||
show ? "visible" : "none" | ||
); | ||
} | ||
} | ||
function tooltip(feature: MapGeoJSONFeature): string { | ||
return `<p>${feature.properties.name}</p>`; | ||
} | ||
function onClick(e: CustomEvent<MapGeoJSONFeature>) { | ||
window.open( | ||
`https://www.ons.gov.uk/visualisations/areas/${e.detail.properties.LAD23CD}`, | ||
"_blank" | ||
); | ||
} | ||
</script> | ||
|
||
<Checkbox id={name} bind:checked={show}> | ||
<ColorLegend {color} /> | ||
Local Authority Districts | ||
<span slot="right"> | ||
<HelpButton> | ||
<p> | ||
Data from <ExternalLink | ||
href="https://geoportal.statistics.gov.uk/datasets/ons::local-authority-districts-may-2023-boundaries-uk-buc/explore" | ||
> | ||
ONS Geography | ||
</ExternalLink>, as of May 2023. | ||
</p> | ||
<p> | ||
License: <ExternalLink | ||
href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" | ||
> | ||
Open Government License | ||
</ExternalLink>. Contains OS data © Crown copyright and database | ||
right 2023. | ||
</p> | ||
</HelpButton> | ||
</span> | ||
</Checkbox> | ||
|
||
<InteractiveLayer layer={name} {tooltip} {show} on:click={onClick} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters