From: Tom Hughes Date: Sun, 18 Aug 2024 11:16:22 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/5083' X-Git-Tag: live~710 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/41b81bd393cafe8fb0d25ccdc3afb08fb695bb52?hp=fb854652ea47d7b3fa1657722f1da768eaba4f25 Merge remote-tracking branch 'upstream/pull/5083' --- diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 24042081d..d111eca35 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -43,25 +43,18 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch setLatLng(latlng); setInputValueFromLatLng(latlng); changeCallback(); - } else { - endpoint.getGeocode(); + } else if (endpoint.value) { + getGeocode(); } }; - endpoint.getGeocode = function () { - // if no one has entered a value yet, then we can't geocode, so don't - // even try. - if (!endpoint.value) { - return; - } - + function getGeocode() { endpoint.awaitingGeocode = true; var viewbox = map.getBounds().toBBoxString(); // ,,, $.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json&viewbox=" + viewbox, function (json) { endpoint.awaitingGeocode = false; - endpoint.hasGeocode = true; if (json.length === 0) { input.addClass("is-invalid"); alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value })); @@ -74,10 +67,9 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch changeCallback(); }); - }; + } function setLatLng(ll) { - endpoint.hasGeocode = true; endpoint.latlng = ll; endpoint.marker .setLatLng(ll) diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index e2cdd3a54..3f78c7089 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -115,18 +115,6 @@ OSM.Directions = function (map) { // Cancel any route that is already in progress if (routeRequest) routeRequest.abort(); - // go fetch geocodes for any endpoints which have not already - // been geocoded. - for (var ep_i = 0; ep_i < 2; ++ep_i) { - var endpoint = endpoints[ep_i]; - if (!endpoint.hasGeocode && !endpoint.awaitingGeocode) { - endpoint.getGeocode(); - } - } - if (endpoints[0].awaitingGeocode || endpoints[1].awaitingGeocode) { - return; - } - var o = endpoints[0].latlng, d = endpoints[1].latlng;