};
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;
if (latlng && endpoint.cachedReverseGeocode && endpoint.cachedReverseGeocode.latlng.equals(latlng)) {
setLatLng(latlng);
- endpoint.value = endpoint.cachedReverseGeocode.value;
+ if (endpoint.cachedReverseGeocode.notFound) {
+ endpoint.value = value;
+ input.addClass("is-invalid");
+ } else {
+ endpoint.value = endpoint.cachedReverseGeocode.value;
+ }
input.val(endpoint.value);
changeCallback();
return;
endpoint.geocodeRequest = $.getJSON(reverseGeocodeUrl, function (json) {
delete endpoint.geocodeRequest;
if (!json || !json.display_name) {
+ endpoint.cachedReverseGeocode = { latlng: latlng, notFound: true };
return;
}
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;
};