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.
This commit is contained in:
Anton Khorev 2024-08-11 06:58:14 +03:00
parent a0013c8f56
commit e624871eb4
2 changed files with 0 additions and 14 deletions

View file

@ -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) { $.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json&viewbox=" + viewbox, function (json) {
endpoint.awaitingGeocode = false; endpoint.awaitingGeocode = false;
endpoint.hasGeocode = true;
if (json.length === 0) { if (json.length === 0) {
input.addClass("is-invalid"); input.addClass("is-invalid");
alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value })); 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) { function setLatLng(ll) {
endpoint.hasGeocode = true;
endpoint.latlng = ll; endpoint.latlng = ll;
endpoint.marker endpoint.marker
.setLatLng(ll) .setLatLng(ll)

View file

@ -119,18 +119,6 @@ OSM.Directions = function (map) {
// Cancel any route that is already in progress // Cancel any route that is already in progress
if (routeRequest) routeRequest.abort(); 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, var o = endpoints[0].latlng,
d = endpoints[1].latlng; d = endpoints[1].latlng;