Skip to content

Commit

Permalink
Cache "not found" reverse geocoding results
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Aug 21, 2024
1 parent 1ae52b8 commit 49d1ab3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/assets/javascripts/index/directions-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch

if (latlng && endpoint.cachedReverseGeocode && endpoint.cachedReverseGeocode.latlng.equals(latlng)) {
setLatLng(latlng);
endpoint.value = endpoint.cachedReverseGeocode.value;
if (endpoint.cachedReverseGeocode.notFound) {
endpoint.value = value;
input.addClass("is-invalid");
} else {
endpoint.value = endpoint.cachedReverseGeocode.value;
}
input.val(endpoint.value);
changeCallback();
return;
Expand Down Expand Up @@ -122,6 +127,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch
if (!json || !json.display_name) {
input.addClass("is-invalid");
alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value }));
endpoint.cachedReverseGeocode = { latlng: latlng, notFound: true };
return;
}

Expand Down

0 comments on commit 49d1ab3

Please sign in to comment.