-
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
9004889
commit 0f36f3b
Showing
5 changed files
with
97 additions
and
0 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
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,91 @@ | ||
<script lang="ts"> | ||
import type { MapGeoJSONFeature } from "maplibre-gl"; | ||
import { | ||
hoveredToggle, | ||
overwriteLineLayer, | ||
overwritePmtilesSource, | ||
overwritePolygonLayer, | ||
} from "../../maplibre_helpers"; | ||
import { map } from "../../stores"; | ||
import { | ||
ColorLegend, | ||
ExternalLink, | ||
HelpButton, | ||
InteractiveLayer, | ||
} from "../common"; | ||
import { Checkbox } from "../govuk"; | ||
import { colors } from "./colors"; | ||
let name = "wards"; | ||
let color = colors.wards; | ||
let outlineLayer = `${name}-outline`; | ||
overwritePmtilesSource( | ||
$map, | ||
name, | ||
`https://atip.uk/layers/v1/${name}.pmtiles` | ||
); | ||
overwritePolygonLayer($map, { | ||
id: name, | ||
source: name, | ||
sourceLayer: name, | ||
color, | ||
opacity: hoveredToggle(0.5, 0.1), | ||
}); | ||
overwriteLineLayer($map, { | ||
id: outlineLayer, | ||
source: name, | ||
sourceLayer: 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>) { | ||
let name = encodeURIComponent(e.detail.properties.name); | ||
// Help people find the councillor for this area | ||
window.open(`https://www.google.com/search?q=${name}+councillor`, "_blank"); | ||
} | ||
</script> | ||
|
||
<Checkbox id={name} bind:checked={show}> | ||
<ColorLegend {color} /> | ||
Wards | ||
<span slot="right"> | ||
<HelpButton> | ||
<p> | ||
Data from <ExternalLink | ||
href="https://geoportal.statistics.gov.uk/datasets/ons::wards-may-2023-boundaries-uk-bgc/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