]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions-endpoint.js
Cache "not found" reverse geocoding results
[rails.git] / app / assets / javascripts / index / directions-endpoint.js
index 6cb94f39ff1ee81ab44d992514c41575956b6a56..6a3cd7c269edda3a3bdbc68f7a73e0ee68fa9683 100644 (file)
@@ -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;
       }