From: Anton Khorev Date: Wed, 21 Aug 2024 10:41:47 +0000 (+0300) Subject: Cache "not found" reverse geocoding results X-Git-Tag: live~62^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/147b3f05d83e79d270a26ee03aa2ef7b231945a1 Cache "not found" reverse geocoding results --- diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 6cb94f39f..6a3cd7c26 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -66,7 +66,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; @@ -123,6 +128,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch endpoint.geocodeRequest = $.getJSON(reverseGeocodeUrl, function (json) { delete endpoint.geocodeRequest; if (!json || !json.display_name) { + endpoint.cachedReverseGeocode = { latlng: latlng, notFound: true }; return; }