mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-07 04:22:09 +00:00
update
This commit is contained in:
@@ -13,11 +13,18 @@ export const latLongToSvgPosition = ({
|
||||
}: Coordinates & { width: number; height: number }) => {
|
||||
const { west, east, north, south } = MAP_BOUNDS;
|
||||
|
||||
const lngRatio = (longitude - west) / (east - west);
|
||||
const latRatio = (latitude - south) / (north - south);
|
||||
// Handle longitude wrapping for coordinates crossing the date line
|
||||
let lng = longitude;
|
||||
if (lng < west) lng += 360;
|
||||
else if (lng > east) lng -= 360;
|
||||
|
||||
const x = Math.max(0, Math.min(1, lngRatio)) * 100;
|
||||
const y = Math.max(0, Math.min(1, 1 - latRatio)) * 100;
|
||||
// Calculate position as percentage of the map bounds
|
||||
const lngRatio = (lng - west) / (east - west);
|
||||
const latRatio = (north - latitude) / (north - south);
|
||||
|
||||
// Convert to percentages clamped between 0-100
|
||||
const x = Math.max(0, Math.min(100, lngRatio * 100));
|
||||
const y = Math.max(0, Math.min(100, latRatio * 100));
|
||||
|
||||
return { x, y };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user