|
@ -178,12 +178,25 @@ export default class extends Controller { |
|
|
window.open(url, '_blank'); |
|
|
window.open(url, '_blank'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
openInPifomap() { |
|
|
|
|
|
const self = this, url1 = "https://geo.api.gouv.fr/communes?lat="+this.mapInstance.getCenter().lat+"&lon="+this.mapInstance.getCenter().lng+"&fields=code,nom"; |
|
|
|
|
|
fetch(url1).then(function (response) { return response.json(); }).then(function (json) { |
|
|
|
|
|
const hasInsee = (Array.isArray(json) && (json.length > 0) && json[0].hasOwnProperty('code')); |
|
|
|
|
|
if (hasInsee) { |
|
|
|
|
|
const url2 = "https://bano.openstreetmap.fr/pifometre/pifomap.html?insee="+json[0].code; |
|
|
|
|
|
window.open(url2, '_blank'); |
|
|
|
|
|
} else { |
|
|
|
|
|
window.alert('Impossible de trouver le code INSEE de la commune…'); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
openInPifometre() { |
|
|
openInPifometre() { |
|
|
const self = this, url1 = "https://nominatim.openstreetmap.org/reverse?format=json&lat="+this.mapInstance.getCenter().lat+"&lon="+this.mapInstance.getCenter().lng+"&zoom="+this.mapInstance.getZoom()+"&extratags=1"; |
|
|
|
|
|
|
|
|
const self = this, url1 = "https://geo.api.gouv.fr/communes?lat="+this.mapInstance.getCenter().lat+"&lon="+this.mapInstance.getCenter().lng+"&fields=code,nom"; |
|
|
fetch(url1).then(function (response) { return response.json(); }).then(function (json) { |
|
|
fetch(url1).then(function (response) { return response.json(); }).then(function (json) { |
|
|
const hasInsee = ((typeof json.extratags === 'undefined') || (json.extratags.hasOwnProperty('ref:INSEE'))); |
|
|
|
|
|
|
|
|
const hasInsee = (Array.isArray(json) && (json.length > 0) && json[0].hasOwnProperty('code')); |
|
|
if (hasInsee) { |
|
|
if (hasInsee) { |
|
|
const url2 = "https://bano.openstreetmap.fr/pifometre/?insee="+json.extratags['ref:INSEE']; |
|
|
|
|
|
|
|
|
const url2 = "https://bano.openstreetmap.fr/pifometre/?insee="+json[0].code; |
|
|
window.open(url2, '_blank'); |
|
|
window.open(url2, '_blank'); |
|
|
} else { |
|
|
} else { |
|
|
window.alert('Impossible de trouver le code INSEE de la commune…'); |
|
|
window.alert('Impossible de trouver le code INSEE de la commune…'); |
|
@ -216,4 +229,8 @@ export default class extends Controller { |
|
|
window.open(url, '_blank'); |
|
|
window.open(url, '_blank'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
openInF4Map() { |
|
|
|
|
|
const url = "https://demo.f4map.com/#lat="+this.mapInstance.getCenter().lat+"&lon="+this.mapInstance.getCenter().lng+"&zoom="+this.mapInstance.getZoom(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |