X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/20f8fadd7b9f29b3b5141ae08cfae8a60e099489..8f387236cee2e842f695b287ae8a85c365bddf9c:/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 3ffb9b498..2cc3ea662 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -27,11 +27,14 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort(); delete endpoint.geocodeRequest; + removeLatLng(); + delete endpoint.value; + input.val(""); map.removeLayer(endpoint.marker); }; function markerDragListener(e) { - var latlng = convertLatLngToZoomPrecision(e.target.getLatLng()); + const latlng = L.latLng(OSM.cropLocation(e.target.getLatLng(), map.getZoom())); setLatLng(latlng); setInputValueFromLatLng(latlng); @@ -106,11 +109,5 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch input.val(latlng.lat + ", " + latlng.lng); } - function convertLatLngToZoomPrecision(latlng) { - var precision = OSM.zoomPrecision(map.getZoom()); - - return L.latLng(latlng.lat.toFixed(precision), latlng.lng.toFixed(precision)); - } - return endpoint; };