]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions-endpoint.js
Merge remote-tracking branch 'upstream/pull/5598'
[rails.git] / app / assets / javascripts / index / directions-endpoint.js
index 6a3cd7c269edda3a3bdbc68f7a73e0ee68fa9683..3fdae7c5413560139ada1e4150957d84523da2c5 100644 (file)
@@ -34,7 +34,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch
   };
 
   function markerDragListener(e) {
-    var latlng = convertLatLngToZoomPrecision(e.target.getLatLng());
+    const latlng = L.latLng(OSM.cropLocation(e.target.getLatLng(), map.getZoom()));
 
     if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort();
     delete endpoint.geocodeRequest;
@@ -108,6 +108,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch
       delete endpoint.geocodeRequest;
       if (json.length === 0) {
         input.addClass("is-invalid");
+        // eslint-disable-next-line no-alert
         alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value }));
         return;
       }
@@ -159,11 +160,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;
 };