diff --git a/public/datavelo/velotraces.json.php b/public/datavelo/velotraces.json.php index 742b060..e98ac1e 100644 --- a/public/datavelo/velotraces.json.php +++ b/public/datavelo/velotraces.json.php @@ -26,5 +26,5 @@ } closedir($dir); // asort($tracks); -echo json_encode($tracks); +echo json_encode($tracks); //, JSON_PRETTY_PRINT); ?> diff --git a/src/helpers/gpxUtil.js b/src/helpers/gpxUtil.js index d844c7a..9565399 100644 --- a/src/helpers/gpxUtil.js +++ b/src/helpers/gpxUtil.js @@ -11,6 +11,16 @@ export const getGpxList = async () => { } } +export const getGeoJsonList = async () => { + try { + const response = await axios.get('https://alix.guillard.fr/data/velo/velotraces.json.php'); + return response.data + } catch (error) { + console.error('oups Error fetching data:', error.message); + return([]) + } +} + export const filterGpxList = (currentYear, currentCountry, allGpxList) => { const loadCountry = currentCountry === 'xx' ? '' : currentCountry; const loadYear = currentYear === 'all' ? '' : currentYear; @@ -54,6 +64,17 @@ export const loadGeoJsonFromGpx = async (url) => { } } +export const loadGeoJsonFromSlug = async (slug) => { + try { + const response = await axios.get(`https://alix.guillard.fr/data/velo/json/${slug}`); + const geojson = response.data + return geojson; + } catch (error) { + console.error('Error fetching geojson data:', error.message); + return + } +} + export const uploadJson = async (geodata) => { console.log("upload", geodata); const body = JSON.stringify(geodata)