X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/06cece27fe691e321cf42a03e3ec08c464ac1444..97bd4579b0850eec450f77d09b11c1c4ad752faa:/app/assets/javascripts/index/directions-endpoint.js diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 30d499ad7..11a70c62f 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -101,13 +101,14 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch }; function getGeocode() { - var viewbox = map.getBounds().toBBoxString(); // ,,, - var geocodeUrl = OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json&viewbox=" + viewbox; + const viewbox = map.getBounds().toBBoxString(), // ,,, + geocodeUrl = OSM.NOMINATIM_URL + "search?" + new URLSearchParams({ q: endpoint.value, format: "json", viewbox }); endpoint.geocodeRequest = $.getJSON(geocodeUrl, function (json) { delete endpoint.geocodeRequest; if (json.length === 0) { input.addClass("is-invalid"); + // eslint-disable-next-line no-alert alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value })); return; } @@ -122,8 +123,9 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch } function getReverseGeocode() { - var latlng = endpoint.latlng.clone(); - var reverseGeocodeUrl = OSM.NOMINATIM_URL + "reverse?lat=" + latlng.lat + "&lon=" + latlng.lng + "&format=json"; + const latlng = endpoint.latlng.clone(), + { lat, lng } = latlng, + reverseGeocodeUrl = OSM.NOMINATIM_URL + "reverse?" + new URLSearchParams({ lat, lon: lng, format: "json" }); endpoint.geocodeRequest = $.getJSON(reverseGeocodeUrl, function (json) { delete endpoint.geocodeRequest;