Skip to content

Commit

Permalink
Show tooltips with road names for snapped waypoints
Browse files Browse the repository at this point in the history
(need to hide popups upstream first)
  • Loading branch information
dabreegster committed Nov 14, 2023
1 parent 714859d commit af7b0a1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/lib/draw/route/RouteControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
>
Avoid doubling back
</Checkbox>
<Checkbox
id="routeSnapperTooltips"
bind:checked={$userSettings.routeSnapperTooltips}
>
Show tooltips with street names
</Checkbox>
</CheckboxGroup>

<GeocoderControls />
10 changes: 9 additions & 1 deletion src/lib/draw/route/RouteSnapperLayer.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<script lang="ts">
import type { Feature } from "geojson";
import { Popup } from "lib/common";
import {
constructMatchExpression,
isLine,
isPoint,
isPolygon,
layerId,
} from "lib/maplibre";
import { userSettings } from "stores";
import {
CircleLayer,
FillLayer,
Expand Down Expand Up @@ -43,7 +45,13 @@
circleRadiusPixels
),
}}
/>
>
<Popup let:props>
{#if $userSettings.routeSnapperTooltips && props.name}
{props.name}
{/if}
</Popup>
</CircleLayer>
<LineLayer
{...layerId("route-lines")}
filter={isLine}
Expand Down
4 changes: 4 additions & 0 deletions src/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function loadUserSettings(): UserSettings {
let settings = {
streetViewImagery: "google",
avoidDoublingBack: false,
routeSnapperTooltips: false,
};

// Be paranoid when loading from local storage, and only copy over valid items
Expand All @@ -94,6 +95,9 @@ function loadUserSettings(): UserSettings {
if (typeof x.avoidDoublingBack == "boolean") {
settings.avoidDoublingBack = x.avoidDoublingBack;
}
if (typeof x.routeSnapperTooltips == "boolean") {
settings.routeSnapperTooltips = x.routeSnapperTooltips;
}
} catch (error) {
console.log(`Couldn't parse userSettings from local storage: ${error}`);
}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface UserSettings {

// From the Route tool
avoidDoublingBack: boolean;
routeSnapperTooltips: boolean;
}

export function isStreetViewImagery(x: string): x is "google" | "bing" {
Expand Down

0 comments on commit af7b0a1

Please sign in to comment.