enable search city, josm edit, copy url
This commit is contained in:
parent
61b7dc601f
commit
df001ab7ff
21
js/main.js
21
js/main.js
@ -692,11 +692,12 @@ function init() {
|
||||
document.getElementById('searchButton').addEventListener('click', searchLocation);
|
||||
}
|
||||
|
||||
|
||||
function copyCurrentUrl() {
|
||||
const url = window.location.href;
|
||||
var dummy = document.createElement('input'),
|
||||
text = window.location.href;
|
||||
|
||||
|
||||
document.body.appendChild(dummy);
|
||||
dummy.value = text;
|
||||
dummy.select();
|
||||
@ -714,13 +715,13 @@ function searchLocation() {
|
||||
const url = `https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(location)}`;
|
||||
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.length > 0) {
|
||||
const place = data[0];
|
||||
const lat = parseFloat(place.lat);
|
||||
const lon = parseFloat(place.lon);
|
||||
map.setView([lat, lon], 13); // Ajustez le niveau de zoom selon vos besoins
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.length > 0) {
|
||||
const place = data[0];
|
||||
const lat = parseFloat(place.lat);
|
||||
const lon = parseFloat(place.lon);
|
||||
map.setView([lat, lon], 13); // Ajustez le niveau de zoom selon vos besoins
|
||||
} else {
|
||||
alert('Lieu non trouvé. Veuillez essayer un autre terme de recherche.');
|
||||
}
|
||||
@ -729,4 +730,6 @@ function searchLocation() {
|
||||
console.error('Erreur lors de la recherche du lieu :', error);
|
||||
alert('Erreur lors de la recherche du lieu.');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
init()
|
Loading…
Reference in New Issue
Block a user