From e624871eb4d871ac4dcfefce3c279aac32c0496d Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 11 Aug 2024 06:58:14 +0300 Subject: [PATCH] Remove endpoint.hasGeocode state and related getRoute code hasGeocode didn't actually indicated if an endpoint has a value acquired from a geocoder. It was set to true when at least one call to a geocoder finished successfully, including getting an empty result. getRoute doesn't need to know what calls were made, it only needs coordinates. It also doesn't get to decide when to fetch coordinates, this is done in drag/change callbacks. --- app/assets/javascripts/index/directions-endpoint.js | 2 -- app/assets/javascripts/index/directions.js | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 24042081d..ec09352de 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -61,7 +61,6 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch $.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 })); @@ -77,7 +76,6 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch }; 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 b34f18ed1..0f3c410f7 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -119,18 +119,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; -- 2.39.5