diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 9477c82f5b..7e8f05cccd 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -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; @@ -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; }