- Creazione "AbitareGliIblei"

- Mappa Interattiva con i markers
This commit is contained in:
Surya Paolo
2024-07-31 15:02:30 +02:00
parent 3ab18b591f
commit 822585cf33
252 changed files with 3600294 additions and 4300 deletions

View File

@@ -0,0 +1,19 @@
// geocoding.ts
export const getCityFromCoordinates = async (lat: number, lon: number): Promise<string | null> => {
const url = `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=json`;
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error('Errore nella richiesta di geocoding');
}
const data = await response.json();
// Controlla se la città è presente nei risultati
return data.address?.city || data.address?.town || data.address?.village || null;
} catch (error) {
console.error('Errore durante il geocoding:', error);
return null;
}
};