mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-16 06:16:07 +02:00
(bug) invalidate repeater panel map tiling on resize. Closes #262.
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
import { MapContainer, TileLayer, CircleMarker, Popup, Polyline } from 'react-leaflet';
|
||||
import { useEffect } from 'react';
|
||||
import { MapContainer, TileLayer, CircleMarker, Popup, Polyline, useMap } from 'react-leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
|
||||
/** Watches the map container for size changes and tells Leaflet to re-tile. */
|
||||
function InvalidateOnResize() {
|
||||
const map = useMap();
|
||||
useEffect(() => {
|
||||
const container = map.getContainer();
|
||||
const ro = new ResizeObserver(() => {
|
||||
map.invalidateSize();
|
||||
});
|
||||
ro.observe(container);
|
||||
return () => ro.disconnect();
|
||||
}, [map]);
|
||||
return null;
|
||||
}
|
||||
|
||||
interface Neighbor {
|
||||
lat: number | null;
|
||||
lon: number | null;
|
||||
@@ -40,6 +55,7 @@ export function NeighborsMiniMap({ neighbors, radioLat, radioLon, radioName }: P
|
||||
className="h-full w-full"
|
||||
style={{ background: '#1a1a2e' }}
|
||||
>
|
||||
<InvalidateOnResize />
|
||||
<TileLayer
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
|
||||
Reference in New Issue
Block a user