diff --git a/src/components/gpx/Gpx.tsx b/src/components/gpx/Gpx.tsx index dcf4e5a..5fb4a0a 100644 --- a/src/components/gpx/Gpx.tsx +++ b/src/components/gpx/Gpx.tsx @@ -13,6 +13,7 @@ import { createCachedSignal, destroyCachedSignal, } from '../../workers/cached-signals'; +import { getTagsFromObj } from '../../lib/tags/tags'; interface Props { gpxId: string; @@ -72,6 +73,7 @@ export const Gpx: Component = ({ map, gpxId }) => { vectorSources={vectorSources} trkId={trkId} context={{ gpx, gpxId }} + tags={getTagsFromObj(gpx())} /> ); diff --git a/src/components/trk/Trk.tsx b/src/components/trk/Trk.tsx index fc6ecdb..056d2d1 100644 --- a/src/components/trk/Trk.tsx +++ b/src/components/trk/Trk.tsx @@ -1,12 +1,4 @@ -import { - Component, - createEffect, - For, - onCleanup, - Suspense, -} from 'solid-js'; - - +import { Component, createEffect, For, onCleanup, Suspense } from 'solid-js'; import Trkseg from '../trkseg'; import VectorSource from 'ol/source/Vector'; @@ -19,8 +11,14 @@ interface Props { trkId: string; vectorSources: VectorSource[]; context: any; + tags: any; } -export const Trk: Component = ({ vectorSources, trkId, context }) => { +export const Trk: Component = ({ + vectorSources, + trkId, + context, + tags, +}) => { const params = { id: trkId, method: 'getTrk', @@ -47,6 +45,7 @@ export const Trk: Component = ({ vectorSources, trkId, context }) => { vectorSources={vectorSources} trksegId={trksegId} context={{ ...context, trk, trkId }} + tags={tags} /> ); diff --git a/src/components/trkseg/Trkseg.tsx b/src/components/trkseg/Trkseg.tsx index 316285d..ac51680 100644 --- a/src/components/trkseg/Trkseg.tsx +++ b/src/components/trkseg/Trkseg.tsx @@ -13,12 +13,14 @@ interface Props { trksegId: string; vectorSources: VectorSource[]; context: any; + tags: any; } export const Trkseg: Component = ({ vectorSources, trksegId, context, + tags, }) => { const params = { id: trksegId, @@ -99,6 +101,7 @@ export const Trkseg: Component = ({ id: trksegId, context: { ...context, trkseg, trksegId }, positions: positions(), + tags, }, id: `${trksegId}/start`, }, diff --git a/src/db/types.d.ts b/src/db/types.d.ts index 73724c6..e9aeab4 100644 --- a/src/db/types.d.ts +++ b/src/db/types.d.ts @@ -55,6 +55,7 @@ interface Extensions { endTime?: string; category?: Category; subCategory?: SubCategory; + tags?: any; } interface Trk { diff --git a/src/lib/tags/tags.ts b/src/lib/tags/tags.ts new file mode 100644 index 0000000..fe39c93 --- /dev/null +++ b/src/lib/tags/tags.ts @@ -0,0 +1,15 @@ +export const getTagsFromObj = (obj: any) => { + if (!obj) { + return {}; + } + + if (!obj.extensions) { + return {}; + } + + if (!obj.extensions.tags) { + return {}; + } + + return obj.extensions.tags; +};