Skip to content

Commit

Permalink
For the street view tool, plumb the map explicitly, so non-sketch cal…
Browse files Browse the repository at this point in the history
…lers can use it easily
  • Loading branch information
dabreegster committed Jul 14, 2024
1 parent d31a77d commit 57196b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/lib/common/StreetViewTool.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@
import { onDestroy } from "svelte";
import cameraCursorUrl from "$lib/assets/camera_cursor.svg?url";
import StreetViewHelp from "./StreetViewHelp.svelte";
import { map, type Config } from "$lib/config";
import type { Map } from "maplibre-gl";
export let cfg: { getStreetViewRoadLayerNames: (map: Map) => string[] };
export let map: Map | null;
export let enabled: boolean;
export let showControls = true;
let defaultLineColorPerLayer: [string, any][] = [];
function on() {
if (!$map) {
if (!map) {
return;
}
$map.on("click", onClick);
$map.getCanvas().style.cursor = `url(${cameraCursorUrl}), auto`;
map.on("click", onClick);
map.getCanvas().style.cursor = `url(${cameraCursorUrl}), auto`;
for (let layer of cfg.getStreetViewRoadLayerNames($map)) {
for (let layer of cfg.getStreetViewRoadLayerNames(map)) {
defaultLineColorPerLayer.push([
layer,
$map.getPaintProperty(layer, "line-color"),
map.getPaintProperty(layer, "line-color"),
]);
$map.setPaintProperty(layer, "line-color", "cyan");
map.setPaintProperty(layer, "line-color", "cyan");
}
}
function off() {
if ($map) {
$map.off("click", onClick);
$map.getCanvas().style.cursor = "inherit";
if (map) {
map.off("click", onClick);
map.getCanvas().style.cursor = "inherit";
for (let [layer, value] of defaultLineColorPerLayer) {
$map.setPaintProperty(layer, "line-color", value);
map.setPaintProperty(layer, "line-color", value);
}
defaultLineColorPerLayer = [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/draw/StreetViewMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { StreetViewHelp, StreetViewTool } from "$lib/common";
import { mode, userSettings } from "$lib/draw/stores";
import { DefaultButton, Radio } from "govuk-svelte";
import type { Config } from "$lib/config";
import { type Config, map } from "$lib/config";
export let cfg: Config<F, S>;
Expand All @@ -12,7 +12,7 @@
}
</script>

<StreetViewTool {cfg} bind:enabled showControls={false} />
<StreetViewTool {cfg} map={$map} bind:enabled showControls={false} />

<DefaultButton on:click={() => (enabled = false)}>Finish</DefaultButton>

Expand Down

0 comments on commit 57196b7

Please sign in to comment.