X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/1fce0c00f12ac6bbb56ad7c05c8c9f53c0d6edb3..d9b09046f2245a201c462dee382ecb940c0a5293:/app/assets/javascripts/index/directions-endpoint.js diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 7fe4b4ea7..59f0b929d 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -36,6 +36,9 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch function markerDragListener(e) { var latlng = convertLatLngToZoomPrecision(e.target.getLatLng()); + if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort(); + delete endpoint.geocodeRequest; + setLatLng(latlng); setInputValueFromLatLng(latlng); endpoint.value = input.val(); @@ -58,6 +61,9 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch input.removeClass("is-invalid"); input.val(value); + if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort(); + delete endpoint.geocodeRequest; + if (latlng) { setLatLng(latlng); setInputValueFromLatLng(latlng); @@ -71,7 +77,6 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch var viewbox = map.getBounds().toBBoxString(); // ,,, var geocodeUrl = OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json&viewbox=" + viewbox; - if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort(); endpoint.geocodeRequest = $.getJSON(geocodeUrl, function (json) { delete endpoint.geocodeRequest; if (json.length === 0) {