fix(site-finder): isochrones map re-renders on mode change (key includes coords hash)
This commit is contained in:
parent
2cbcea9e73
commit
99ca42e5d0
1 changed files with 13 additions and 2 deletions
|
|
@ -144,7 +144,11 @@ export function SiteMap({ data, isochrones }: Props) {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Isochrones — render in reverse order (largest range at bottom) */}
|
{/* Isochrones — render in reverse order (largest range at bottom).
|
||||||
|
NB: react-leaflet GeoJSON кэширует слой, не реагирует на смену
|
||||||
|
`data` prop. Включаем в key первую координату feature (она
|
||||||
|
различается между mode=foot/cycle/car и временем) — это
|
||||||
|
форсирует remount при пересчёте от ORS. */}
|
||||||
{isochrones &&
|
{isochrones &&
|
||||||
[...isochrones.features].reverse().map((feature, idx) => {
|
[...isochrones.features].reverse().map((feature, idx) => {
|
||||||
const seconds =
|
const seconds =
|
||||||
|
|
@ -159,9 +163,16 @@ export function SiteMap({ data, isochrones }: Props) {
|
||||||
: minutes <= 20
|
: minutes <= 20
|
||||||
? "#3b82f6"
|
? "#3b82f6"
|
||||||
: "#a855f7";
|
: "#a855f7";
|
||||||
|
// Hash из первой координаты — различает foot/cycle/car полигоны
|
||||||
|
const firstCoord = (
|
||||||
|
feature.geometry as { coordinates?: number[][][] }
|
||||||
|
)?.coordinates?.[0]?.[0];
|
||||||
|
const coordHash = firstCoord
|
||||||
|
? `${firstCoord[0].toFixed(4)},${firstCoord[1].toFixed(4)}`
|
||||||
|
: `${idx}`;
|
||||||
return (
|
return (
|
||||||
<GeoJSON
|
<GeoJSON
|
||||||
key={`iso-${idx}-${seconds}`}
|
key={`iso-${seconds}-${coordHash}`}
|
||||||
data={feature as Feature}
|
data={feature as Feature}
|
||||||
style={{
|
style={{
|
||||||
color,
|
color,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue