Make setLatLng a private function

This commit is contained in:
Anton Khorev 2024-08-11 05:31:48 +03:00
parent f65593651f
commit f1ca64ff84

View file

@ -17,7 +17,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ge
endpoint.marker.on("drag dragend", function (e) {
var latlng = e.target.getLatLng();
endpoint.setLatLng(latlng);
setLatLng(latlng);
setInputValueFromLatLng(latlng);
endpoint.value = input.val();
dragCallback(e.type === "drag");
@ -40,7 +40,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ge
input.val(value);
if (latlng) {
endpoint.setLatLng(latlng);
setLatLng(latlng);
setInputValueFromLatLng(latlng);
} else {
endpoint.getGeocode();
@ -67,7 +67,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ge
return;
}
endpoint.setLatLng(L.latLng(json[0]));
setLatLng(L.latLng(json[0]));
input.val(json[0].display_name);
@ -75,13 +75,13 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ge
});
};
endpoint.setLatLng = function (ll) {
function setLatLng(ll) {
endpoint.hasGeocode = true;
endpoint.latlng = ll;
endpoint.marker
.setLatLng(ll)
.addTo(map);
};
}
function setInputValueFromLatLng(latlng) {
var precision = OSM.zoomPrecision(map.getZoom());