Skip to content

Commit

Permalink
Merge pull request #1251 from jorgeart81/fix-mapview/prevent-reset-zoom
Browse files Browse the repository at this point in the history
Update the itemsCoordinates state every time the length of itemsRoute…
  • Loading branch information
tananaev authored Jun 29, 2024
2 parents 7596053 + fd3a8a1 commit 66b964c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/reports/CombinedReportPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
import {
Table, TableBody, TableCell, TableHead, TableRow,
Expand Down Expand Up @@ -27,6 +27,8 @@ const CombinedReportPage = () => {
const [items, setItems] = useState([]);
const [loading, setLoading] = useState(false);

const itemsCoordinates = useMemo(() => items.flatMap((item) => item.route), [items]);

const createMarkers = () => items.flatMap((item) => item.events
.map((event) => item.positions.find((p) => event.positionId === p.id))
.filter((position) => position != null)
Expand Down Expand Up @@ -68,7 +70,7 @@ const CombinedReportPage = () => {
))}
<MapMarkers markers={createMarkers()} />
</MapView>
<MapCamera coordinates={items.flatMap((item) => item.route)} />
<MapCamera coordinates={itemsCoordinates} />
</div>
)}
<div className={classes.containerMain}>
Expand Down

0 comments on commit 66b964c

Please sign in to comment.