@@ -3,8 +3,8 @@ import Map, {Layer, NavigationControl, Popup, Source} from "react-map-gl/maplibr
33import "maplibre-gl/dist/maplibre-gl.css" ;
44import { format , formatDistanceToNow } from "date-fns" ;
55import type { StoredLocation } from "../gen/common.ts" ;
6- import { type MapGeoJSONFeature } from "maplibre-gl" ;
7- import type { Point } from "geojson" ;
6+ import type { MapGeoJSONFeature , StyleSpecification } from "maplibre-gl" ;
7+ import type { FeatureCollection , Feature , Point , LineString } from "geojson" ;
88import { Segmented } from "antd" ;
99import { useLocalStorage } from "../hooks/use-local-storage.ts" ;
1010import styles from "./MLMap.module.css" ;
@@ -41,14 +41,14 @@ export const MLMap: React.FC<MLMapProps> = ({history, selectedDeviceId, forceRec
4141 return ( ) => clearInterval ( interval ) ;
4242 } , [ ] ) ;
4343
44- const pointData = useMemo ( ( ) => {
44+ const pointData : FeatureCollection < Point > = useMemo ( ( ) => {
4545 return {
4646 type : "FeatureCollection" ,
4747 features : history
4848 . filter ( h => ! ! h . location )
4949 . slice ( - POINT_LIMIT )
5050 . map ( ( h , index , locations ) => ( {
51- type : "Feature" ,
51+ type : "Feature" as const ,
5252 properties : {
5353 lat : h . location ! . lat ,
5454 lon : h . location ! . lon ,
@@ -58,19 +58,19 @@ export const MLMap: React.FC<MLMapProps> = ({history, selectedDeviceId, forceRec
5858 isLatest : index === locations . length - 1
5959 } ,
6060 geometry : {
61- type : "Point" ,
61+ type : "Point" as const ,
6262 coordinates : [ h . location ! . lon , h . location ! . lat ]
6363 }
6464 } ) )
6565 } ;
6666 } , [ history ] ) ;
6767
68- const lineData = useMemo ( ( ) => {
68+ const lineData : Feature < LineString > = useMemo ( ( ) => {
6969 return {
70- type : "Feature" ,
70+ type : "Feature" as const ,
7171 properties : { } ,
7272 geometry : {
73- type : "LineString" ,
73+ type : "LineString" as const ,
7474 coordinates : history
7575 . filter ( h => ! ! h . location )
7676 . map ( h => [ h . location ! . lon , h . location ! . lat ] )
@@ -130,7 +130,7 @@ export const MLMap: React.FC<MLMapProps> = ({history, selectedDeviceId, forceRec
130130 zoom : DEFAULT_ZOOM
131131 } }
132132 style = { { width : "100%" , height : "100%" } }
133- mapStyle = { mapUrl as any }
133+ mapStyle = { mapUrl as StyleSpecification | string }
134134 interactiveLayerIds = { [ "history-points" ] }
135135 cursor = { cursor }
136136 onMouseEnter = { ( ) => setCursor ( "pointer" ) }
@@ -154,18 +154,18 @@ export const MLMap: React.FC<MLMapProps> = ({history, selectedDeviceId, forceRec
154154 < NavigationControl position = "bottom-right" />
155155
156156 { /* Line */ }
157- < Source type = "geojson" data = { lineData as any } lineMetrics = { true } >
158- < Layer { ...lineStyle ( cutoffRatio ) as any } />
157+ < Source type = "geojson" data = { lineData } lineMetrics = { true } >
158+ < Layer { ...lineStyle ( cutoffRatio ) } />
159159 </ Source >
160160
161161 { /* Points */ }
162- < Source type = "geojson" data = { pointData as any } >
163- < Layer { ...pointStyle as any } />
162+ < Source type = "geojson" data = { pointData } >
163+ < Layer { ...pointStyle } />
164164 </ Source >
165165
166166 { accuracyCircle && (
167167 < Source id = "accuracy-zone" type = "geojson" data = { accuracyCircle } >
168- < Layer { ...accuracyCircleStyle as any } />
168+ < Layer { ...accuracyCircleStyle } />
169169 </ Source >
170170 ) }
171171
0 commit comments