Skip to content

Commit

Permalink
fix(map): limit to max 500 locations
Browse files Browse the repository at this point in the history
since clustering is not implemented yet
and locations are rendered individually
and not as a GeoJSON layer, larger amounts
do not perform well.
  • Loading branch information
coderbyheart committed Dec 9, 2024
1 parent 14ec2bd commit aae06f5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/map/HistoryControls.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { TimeSpan } from '#api/api.js'
import { timeSpans, type TimeSpanInfo } from '#chart/timeSpans.js'
import { useDeviceLocation } from '#context/DeviceLocation.js'
import { formatInt } from '#utils/format.js'
import { HistoryIcon } from 'lucide-preact'
import { useState } from 'preact/hooks'

const byTimeSpan = (timeSpan: TimeSpan | undefined) => (t: TimeSpanInfo) =>
t.id === timeSpan

export const HistoryControls = () => {
const { timeSpan, clustering, enableClustering, setTimeSpan } =
const { timeSpan, clustering, enableClustering, setTimeSpan, trail } =
useDeviceLocation()
const [expanded, setExpanded] = useState<boolean>(false)

Expand All @@ -26,9 +27,14 @@ export const HistoryControls = () => {
setExpanded(true)
}}
>
<span>
History: {timeSpans.find(byTimeSpan(timeSpan))?.title ?? 'off'}
</span>
{trail.length >= 500 && (
<span>last {formatInt(trail.length)} locations</span>
)}
{trail.length < 500 && (
<span>
History: {timeSpans.find(byTimeSpan(timeSpan))?.title ?? 'off'}
</span>
)}
</button>
</div>
)
Expand Down

0 comments on commit aae06f5

Please sign in to comment.