From: Anton Khorev Date: Mon, 12 Aug 2024 02:39:58 +0000 (+0300) Subject: Save lat/lon to input data attributes X-Git-Tag: live~688^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/4f3576e91bcad927f037cd0f5a962960b9b2a8b5?ds=sidebyside Save lat/lon to input data attributes --- diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 87bd112ca..3ffb9b498 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -51,7 +51,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch endpoint.setValue = function (value, latlng) { endpoint.value = value; - delete endpoint.latlng; + removeLatLng(); input.removeClass("is-invalid"); input.val(value); @@ -86,12 +86,22 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch } function setLatLng(ll) { + input + .attr("data-lat", ll.lat) + .attr("data-lon", ll.lng); endpoint.latlng = ll; endpoint.marker .setLatLng(ll) .addTo(map); } + function removeLatLng() { + input + .removeAttr("data-lat") + .removeAttr("data-lon"); + delete endpoint.latlng; + } + function setInputValueFromLatLng(latlng) { input.val(latlng.lat + ", " + latlng.lng); }