mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
fix(map): draw points of interest on the world copy the view is on
POIs fetched for a view west of the trip frame's seam were drawn one world away, off screen.
This commit is contained in:
@@ -57,6 +57,23 @@ export function ViewportController({ onViewportChange }: { onViewportChange?: Ma
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the longitude of the view's centre once the map is laid out and after every
|
||||
* move, for the layers drawn on the world copy in view rather than in the trip's frame.
|
||||
*/
|
||||
export function ViewCenterTracker({ onChange }: { onChange: (centerLng: number) => void }) {
|
||||
const map = useMap();
|
||||
useEffect(() => {
|
||||
const emit = () => onChange(map.getCenter().lng);
|
||||
map.whenReady(emit);
|
||||
map.on('moveend', emit);
|
||||
return () => {
|
||||
map.off('moveend', emit);
|
||||
};
|
||||
}, [map, onChange]);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the view along when the longitude frame changes under it (#2975): the trip
|
||||
* is then drawn one world further east or west, and a view left where it was would
|
||||
|
||||
Reference in New Issue
Block a user