diff --git a/src/main/webapp/src/components/Club/LocationEditor.jsx b/src/main/webapp/src/components/Club/LocationEditor.jsx index 086e82f..a1e99d1 100644 --- a/src/main/webapp/src/components/Club/LocationEditor.jsx +++ b/src/main/webapp/src/components/Club/LocationEditor.jsx @@ -98,15 +98,19 @@ export function LocationEditorModal({modal, sendData}) { return const delayDebounceFn = setTimeout(() => { - refresh(`https://api-adresse.data.gouv.fr/search/?q=${encodeURI(location)}&type=housenumber&autocomplete=1`) + refresh(`https://api-adresse.data.gouv.fr/search/?q=${encodeURI(location)}&type=housenumber&autocomplete=1&limit=5`) }, 500) return () => clearTimeout(delayDebounceFn) }, [location]); useEffect(() => { - if (data?.features?.length === 1) { - const {lat, lng} = convertLambert93ToLatLng(data.features[0].properties.x, data.features[0].properties.y) - setLocationObj({text: data.features[0].properties.label, lng: lng, lat: lat}) + if (data.features?.some((e) => e.properties.label === location)) { + data.features.forEach((d) => { + if (d.properties.label === location) { + const {lat, lng} = convertLambert93ToLatLng(d.properties.x, d.properties.y) + setLocationObj({text: d.properties.label, lng: lng, lat: lat}) + } + }) } else { setLocationObj({text: "", lng: undefined, lat: undefined}) } @@ -144,14 +148,17 @@ export function LocationEditorModal({modal, sendData}) {