Commit d8944a83 authored by Sp3r4z's avatar Sp3r4z
Browse files

[Script] Fix typos + click only France

parent f9cff897
......@@ -96,22 +96,24 @@ L.Control.geocoder({
.addTo(theMap)
theMap.on('click', (e) => {
let lat = e.latlng.lat
let lon = e.latlng.lng
let reverse = `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=json&zoom=18`
let lat = e.latlng.lat,
lon = e.latlng.lng,
reverse = `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=json&zoom=18`
fetch(reverse)
.then(response => response.json()
.then(datas => {
// https://nominatim.org/release-docs/develop/api/Reverse/
// le "county" ne donne pas toujours le département mais on a le postcode qui lui est toujours juste CQFD
// comme à Marseille (inexistant) ou Lyon (Métropole de lyon au lieu de rhone)
.then(response => response.json())
.then(datas => {
// https://nominatim.org/release-docs/develop/api/Reverse/
// le "county" ne donne pas toujours le département mais on a le postcode qui lui est toujours juste CQFD
// comme à Marseille (inexistant) ou Lyon (Métropole de lyon au lieu de rhone)
if(datas.address != undefined && datas.address.country == 'France') {
let departementRef = datas.address.postcode.substring(0,2)
createPoint(lat,lon,departementRef)
})
)
}
})
})
const customControlClean = L.Control.extend({
options: {
position: 'topleft'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment