Skip to content

Commit

Permalink
fix: empty coords (#1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierJp committed May 16, 2024
1 parent df9a15e commit 9811d81
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions components/map/map-etablissement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ function checkLatLng(latitude: string, longitude: string): LngLatLike | null {
try {
const lat = parseFloat(latitude);
const lng = parseFloat(longitude);

if (lat < -90 || lat > 90) {
throw new Error('Invalid latitude');
}

if (lng < -180 || lng > 180) {
throw new Error('Invalid latitude');
if (
isNaN(lat) ||
isNaN(lng) ||
lat < -90 ||
lat > 90 ||
lng < -180 ||
lng > 180
) {
throw new Error('Invalid coords');
}

return {
Expand Down Expand Up @@ -84,9 +86,8 @@ export function MapEtablissement({
) : (
<i>
Nous n’avons pas réussi à déterminer la géolocalisation de cet
établissement, car ses coordonnées (latitude :{' '}
{etablissement.latitude}°, longitude : {etablissement.longitude}°)
sont invalides.
établissement, car ses coordonnées sont invalides ou inconnues : [
{etablissement.latitude || '⎽'}°, {etablissement.longitude || '⎽'}°].
</i>
)}
</div>
Expand Down

0 comments on commit 9811d81

Please sign in to comment.