Revize 11fca75a
Přidáno uživatelem Václav Honzík před asi 2 roky(ů)
frontend/src/features/TrackingTool/trackingToolSlice.ts | ||
---|---|---|
31 | 31 |
currentPage: 0, |
32 | 32 |
} |
33 | 33 |
|
34 |
// Returns tuple of average latitude and longitude |
|
35 |
const calculateMapCenter = (pathVariant: PathVariant): LatLngTuple => [ |
|
36 |
pathVariant |
|
37 |
.map((item) => item.catalogItem.latitude ?? 0) |
|
38 |
.reduce((a, b) => a + b, 0) / pathVariant.length, |
|
39 |
pathVariant |
|
40 |
.map((item) => item.catalogItem.longitude ?? 0) |
|
41 |
.reduce((a, b) => a + b, 0) / pathVariant.length, |
|
42 |
] |
|
34 |
const calculateMapCenter = (pathVariant: PathVariant): LatLngTuple | undefined => { |
|
35 |
const displayableItems = pathVariant.filter((item) => item.displayable) |
|
36 |
if (displayableItems.length === 0) { |
|
37 |
return undefined |
|
38 |
} |
|
39 |
|
|
40 |
return [ |
|
41 |
displayableItems |
|
42 |
.map((item) => item.catalogItem.latitude ?? 0) |
|
43 |
.reduce((a, b) => a + b, 0) / displayableItems.length, |
|
44 |
displayableItems |
|
45 |
.map((item) => item.catalogItem.longitude ?? 0) |
|
46 |
.reduce((a, b) => a + b, 0) / displayableItems.length, |
|
47 |
] |
|
48 |
} |
|
43 | 49 |
|
44 | 50 |
const persistConfig = { |
45 | 51 |
key: "auth", |
... | ... | |
93 | 99 |
builder.addCase(sendTextForProcessing.fulfilled, (state, action) => { |
94 | 100 |
const pathDto: PathDto = action.payload |
95 | 101 |
const pathVariants = buildPathVariants(pathDto) |
102 |
|
|
103 |
const mapCenter = calculateMapCenter(pathVariants[state.primaryPathIdx]) |
|
96 | 104 |
return { |
97 | 105 |
...state, |
98 | 106 |
pathVariants, |
99 | 107 |
pathDto, |
100 |
// TODO calculate correctly |
|
101 |
mapCenter: |
|
102 |
pathVariants.length > 0 |
|
103 |
? calculateMapCenter(pathVariants[0]) |
|
104 |
: (state.mapCenter as LatLngTuple), |
|
108 |
mapCenter: mapCenter ?? state.mapCenter, |
|
105 | 109 |
isLoading: false, |
106 | 110 |
dialogApiCallSuccess: true, |
107 | 111 |
currentPage: 0, |
Také k dispozici: Unified diff
autozoom + file upload
re #9741