mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 00:32:33 +00:00
store settings
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
import { CircleHelp } from 'lucide-svelte';
|
||||
|
||||
import { map, selectedFiles, Tool } from '$lib/stores';
|
||||
import { brouterProfiles, privateRoads, routing, routingProfile } from './Routing';
|
||||
import { settings } from '$lib/db';
|
||||
import { brouterProfiles, routingProfileSelectItem } from './Routing';
|
||||
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { get } from 'svelte/store';
|
||||
@@ -23,6 +24,8 @@
|
||||
let selectedId: string | null = null;
|
||||
let active = false;
|
||||
|
||||
const { privateRoads, routing } = settings;
|
||||
|
||||
$: if ($map) {
|
||||
// remove controls for deleted files
|
||||
routingControls.forEach((controls, fileId) => {
|
||||
@@ -82,7 +85,7 @@
|
||||
<ToolbarItemMenu tool={Tool.ROUTING} bind:active>
|
||||
<div class="w-full flex flex-row justify-between items-center gap-2">
|
||||
<Label>{$_('toolbar.routing.activity')}</Label>
|
||||
<Select.Root bind:selected={$routingProfile}>
|
||||
<Select.Root bind:selected={$routingProfileSelectItem}>
|
||||
<Select.Trigger class="h-8 w-40">
|
||||
<Select.Value />
|
||||
</Select.Trigger>
|
||||
|
@@ -1,8 +1,11 @@
|
||||
import type { Coordinates } from "gpx";
|
||||
import { TrackPoint } from "gpx";
|
||||
import { get, writable } from "svelte/store";
|
||||
import { settings } from "$lib/db";
|
||||
import { _ } from "svelte-i18n";
|
||||
|
||||
const { routing, routingProfile, privateRoads } = settings;
|
||||
|
||||
export const brouterProfiles: { [key: string]: string } = {
|
||||
bike: 'Trekking-dry',
|
||||
racing_bike: 'fastbike',
|
||||
@@ -12,12 +15,24 @@ export const brouterProfiles: { [key: string]: string } = {
|
||||
water: 'river',
|
||||
railway: 'rail'
|
||||
};
|
||||
export const routingProfile = writable({
|
||||
export const routingProfileSelectItem = writable({
|
||||
value: 'bike',
|
||||
label: get(_)('toolbar.routing.activities.bike')
|
||||
});
|
||||
export const routing = writable(true);
|
||||
export const privateRoads = writable(false);
|
||||
routingProfile.subscribe((value) => {
|
||||
if (value !== get(routingProfileSelectItem).value) {
|
||||
routingProfileSelectItem.update((item) => {
|
||||
item.value = value;
|
||||
item.label = get(_)(`toolbar.routing.activities.${value}`);
|
||||
return item;
|
||||
});
|
||||
}
|
||||
});
|
||||
routingProfileSelectItem.subscribe((item) => {
|
||||
if (item.value !== get(routingProfile)) {
|
||||
routingProfile.set(item.value);
|
||||
}
|
||||
});
|
||||
|
||||
export function route(points: Coordinates[]): Promise<TrackPoint[]> {
|
||||
if (get(routing)) {
|
||||
|
Reference in New Issue
Block a user