Open this example in the interactive library
Live preview
Source code
// components/CoordinateDegreeMinuteDisplay.tsx
export default function CoordinateDegreeMinuteDisplay({
lat = 43.65,
lon = -79.38,
}: { lat?: number; lon?: number } = {}) {
const fmt = (x: number) =>
Math.floor(Math.abs(x)) + "° " + ((Math.abs(x) % 1) * 60).toFixed(2) + "′";
return (
<p>
{fmt(lat)} {lat < 0 ? "S" : "N"} / {fmt(lon)} {lon < 0 ? "W" : "E"}
</p>
);
}
