From 147b3f05d83e79d270a26ee03aa2ef7b231945a1 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Wed, 21 Aug 2024 13:41:47 +0300 Subject: [PATCH] Cache "not found" reverse geocoding results --- app/assets/javascripts/index/directions-endpoint.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } -- 2.39.5