«
Předchozí
|
Další
»
Revize 14588cb6
Přidáno uživatelem Václav Honzík před asi 2 roky(ů)
- ID 14588cb653e6b7358e0e641cc2b8d45dc27b5cf8
- Rodič fc8a530f
frontend/src/features/TrackingTool/trackingToolUtils.ts | ||
---|---|---|
1 | 1 |
|
2 | 2 |
import L, { LatLngTuple, PointExpression } from 'leaflet' |
3 | 3 |
import { CatalogItemDto } from '../../swagger/data-contracts' |
4 |
import generateUuid from '../../utils/id/uuidGenerator' |
|
4 | 5 |
|
5 | 6 |
// For more comprehensive code alias CatalogItemDto[] as path variant |
6 | 7 |
export type PathVariant = MapPoint[] |
... | ... | |
14 | 15 |
|
15 | 16 |
// Represents a point on the map - wrapper for CatalogItemDto to make it easier to work with |
16 | 17 |
export interface MapPoint { |
17 |
id: string // unique id for react |
|
18 |
id: string // unique id to identify the point on the map |
|
19 |
reactId: string // unique id to identify item in React - e.g. rendering in a list |
|
18 | 20 |
idx: number, |
19 | 21 |
addToPath: boolean, // whether to add the point to the path |
20 | 22 |
catalogItem: CatalogItemDto, |
... | ... | |
65 | 67 |
[MapPointType.FromCoordinates]: createMapMarkerSvg('#21972D'), |
66 | 68 |
} |
67 | 69 |
|
68 |
const iconAnchor = [25, 25] as PointExpression
|
|
69 |
const iconSize = [40, 40] as PointExpression
|
|
70 |
const iconAnchor = [22, 22] as PointExpression
|
|
71 |
const iconSize = [35, 35] as PointExpression
|
|
70 | 72 |
|
71 | 73 |
const mapMarkers = { |
72 | 74 |
[MapPointType.LocalCatalog]: L.icon({ |
... | ... | |
104 | 106 |
.map((item) => item.catalogItem.longitude ?? 0) |
105 | 107 |
.reduce((a, b) => a + b, 0) / displayableItems.length, |
106 | 108 |
] |
107 |
} |
|
109 |
} |
|
110 |
|
|
111 |
export const setMapPointIds = (pathVariant: PathVariant): PathVariant => pathVariant.map(mapPoint => { |
|
112 |
// Get identifier - either catalog item identifier is used or generate a new UUID if the point does not have uuid |
|
113 |
// - e.g. is not from the catalog |
|
114 |
mapPoint.id = mapPoint.catalogItem.id ? mapPoint.catalogItem.id : generateUuid() |
|
115 |
return mapPoint |
|
116 |
}) |
Také k dispozici: Unified diff
fixed keys and indices
re #9741