Skip to content

Commit 19cfdb7

Browse files
committed
fixed points info alignment and also clicking on side panel
1 parent 7972aaa commit 19cfdb7

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

frontend/src/components/HUDleftPoints.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ function LogoBlock() {
404404
position: 'absolute',
405405
top: 'calc(100% + 0.25rem)',
406406
right: 0,
407-
backgroundColor: theme === 'light' ? '#e6e6e6bb' : '#00000086',
407+
backgroundColor: theme === 'light' ? '#dadadae1' : '#242424f1',
408408
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
409409
color: theme === 'light' ? '#000' : '#fff',
410410
borderRadius: '1rem',

frontend/src/components/MapComponent.jsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,31 @@ export default function MapComponent() {
251251

252252
const historicalData = await fetchHistoricalData(name);
253253

254+
// add once at top of click‐handler so you can reuse
255+
const popupOffset = [17, -25]; // x=0 (center), y=−45px (above marker)
256+
254257
if (historicalData.length === 0) {
255258
marker.bindPopup(`
256259
<div role="dialog" aria-labelledby="popup-title-${i}">
257260
<h3 id="popup-title-${i}">${name}</h3>
258261
<p>No historical data available</p>
259262
<p>Current temperature: ${formattedTemp} (${tempCategory})</p>
260263
</div>
261-
`).openPopup();
264+
`, {
265+
offset: popupOffset,
266+
className: 'custom-popup'
267+
}).openPopup();
262268
return;
263269
}
264270

265271
if (historicalData.length < 2) {
266-
marker.bindPopup(`<strong>${name}</strong><br/>Not enough data to generate a graph`).openPopup();
272+
marker.bindPopup(
273+
`<strong>${name}</strong><br/>Not enough data to generate a graph`,
274+
{
275+
offset: popupOffset,
276+
className: 'custom-popup'
277+
}
278+
).openPopup();
267279
return;
268280
}
269281

@@ -438,7 +450,7 @@ export default function MapComponent() {
438450

439451
// Open popup
440452
const popup = L.popup({
441-
offset: [10, -20],
453+
offset: popupOffset,
442454
maxWidth: 650,
443455
maxHeight: 470,
444456
className: 'custom-popup'
@@ -779,10 +791,10 @@ export default function MapComponent() {
779791
map.once('moveend', function() {
780792
// After panning completes, smoothly zoom in
781793
map.once('zoomend', function() {
782-
// Find and open any popup that might be at this location
783-
markersRef.current.forEach(({marker, lat: markerLat, lon: markerLon}) => {
794+
// replace marker.openPopup() with marker.fire('click')
795+
markersRef.current.forEach(({ marker, lat: markerLat, lon: markerLon }) => {
784796
if (Math.abs(markerLat - lat) < 0.0001 && Math.abs(markerLon - lon) < 0.0001) {
785-
marker.openPopup();
797+
marker.fire('click');
786798
}
787799
});
788800
});
@@ -828,13 +840,13 @@ export default function MapComponent() {
828840
map.once('moveend', function() {
829841
// After panning completes, smoothly zoom in
830842
map.once('zoomend', function() {
831-
// After zooming completes, open the popup
832-
match.marker.openPopup();
843+
// fire the click event so your click-handler builds the popup & chart
844+
match.marker.fire('click');
833845
});
834846

835847
// Animate zoom with a duration in ms
836848
map.flyTo(offsetLatLng, targetZoom, {
837-
duration: 0.5, // seconds
849+
duration: 0.5,
838850
easeLinearity: 0.2
839851
});
840852
});

0 commit comments

Comments
 (0)