Revize 48690561
Přidáno uživatelem Václav Honzík před asi 2 roky(ů)
frontend/src/features/TrackingTool/trackingToolUtils.ts | ||
---|---|---|
1 |
import L, { PointExpression } from 'leaflet' |
|
1 |
|
|
2 |
import L, { LatLngTuple, PointExpression } from 'leaflet' |
|
2 | 3 |
import { CatalogItemDto } from '../../swagger/data-contracts' |
3 |
import { mdiMapMarker } from '@mdi/js' |
|
4 | 4 |
|
5 | 5 |
// For more comprehensive code alias CatalogItemDto[] as path variant |
6 | 6 |
export type PathVariant = MapPoint[] |
... | ... | |
88 | 88 |
}), |
89 | 89 |
} |
90 | 90 |
|
91 |
export const getMapPointIcon = (item: MapPoint): L.Icon => mapMarkers[item.type] |
|
91 |
export const getMapPointIcon = (item: MapPoint): L.Icon => mapMarkers[item.type] |
|
92 |
|
|
93 |
export const calculateMapCenter = (pathVariant: PathVariant): LatLngTuple | undefined => { |
|
94 |
const displayableItems = pathVariant.filter((item) => isMapPointDisplayable(item)) |
|
95 |
if (displayableItems.length === 0) { |
|
96 |
return undefined |
|
97 |
} |
|
98 |
|
|
99 |
return [ |
|
100 |
displayableItems |
|
101 |
.map((item) => item.catalogItem.latitude ?? 0) |
|
102 |
.reduce((a, b) => a + b, 0) / displayableItems.length, |
|
103 |
displayableItems |
|
104 |
.map((item) => item.catalogItem.longitude ?? 0) |
|
105 |
.reduce((a, b) => a + b, 0) / displayableItems.length, |
|
106 |
] |
|
107 |
} |
Také k dispozici: Unified diff
smol refactor
re #9741