observatory
This commit is contained in:
parent
125c16b6f6
commit
506e9f8f05
@ -119,6 +119,7 @@ export function ObservatoryMap({
|
|||||||
selectedCountry
|
selectedCountry
|
||||||
}: ObservatoryMapProps) {
|
}: ObservatoryMapProps) {
|
||||||
const [isMounted, setIsMounted] = useState(false);
|
const [isMounted, setIsMounted] = useState(false);
|
||||||
|
const [mapKey, setMapKey] = useState(Date.now()); // Unique key for map container
|
||||||
|
|
||||||
// We'll need the Leaflet CSS
|
// We'll need the Leaflet CSS
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -154,6 +155,12 @@ export function ObservatoryMap({
|
|||||||
}
|
}
|
||||||
|
|
||||||
setIsMounted(true);
|
setIsMounted(true);
|
||||||
|
|
||||||
|
// Return cleanup function
|
||||||
|
return () => {
|
||||||
|
// Generate a new key if the component is unmounted and remounted
|
||||||
|
setMapKey(Date.now());
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Prepare countries with coordinates
|
// Prepare countries with coordinates
|
||||||
@ -210,6 +217,7 @@ export function ObservatoryMap({
|
|||||||
return (
|
return (
|
||||||
<div className="w-full h-full">
|
<div className="w-full h-full">
|
||||||
<MapContainer
|
<MapContainer
|
||||||
|
key={mapKey} // Add a unique key to ensure the map is only initialized once
|
||||||
center={[20, 0]} // Center of the world
|
center={[20, 0]} // Center of the world
|
||||||
zoom={2}
|
zoom={2}
|
||||||
style={{ height: '100%', width: '100%' }}
|
style={{ height: '100%', width: '100%' }}
|
||||||
|
|||||||
@ -186,7 +186,9 @@ export function ObservatoryView() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-grow">
|
<div className="flex-grow">
|
||||||
|
{!loading && (
|
||||||
<ObservatoryMap
|
<ObservatoryMap
|
||||||
|
key="observatory-map"
|
||||||
countries={Object.entries(countriesMap).map(([name, items]) => ({
|
countries={Object.entries(countriesMap).map(([name, items]) => ({
|
||||||
name,
|
name,
|
||||||
count: items.length
|
count: items.length
|
||||||
@ -194,6 +196,7 @@ export function ObservatoryView() {
|
|||||||
onCountrySelect={handleCountrySelect}
|
onCountrySelect={handleCountrySelect}
|
||||||
selectedCountry={selectedCountry}
|
selectedCountry={selectedCountry}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user