From 4f3576e91bcad927f037cd0f5a962960b9b2a8b5 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 12 Aug 2024 05:39:58 +0300 Subject: [PATCH] Save lat/lon to input data attributes --- app/assets/javascripts/index/directions-endpoint.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); } -- 2.39.5