+ endpoint.enable = function () {
+ endpoint.marker.on("drag dragend", markerDragListener);
+ input.on("keydown", inputKeydownListener);
+ input.on("change", inputChangeListener);
+ };
+
+ endpoint.disable = function () {
+ endpoint.marker.off("drag dragend", markerDragListener);
+ input.off("keydown", inputKeydownListener);
+ input.off("change", inputChangeListener);
+
+ if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort();
+ delete endpoint.geocodeRequest;
+ removeLatLng();
+ delete endpoint.value;
+ input.val("");
+ map.removeLayer(endpoint.marker);
+ };
+
+ function markerDragListener(e) {
+ var latlng = convertLatLngToZoomPrecision(e.target.getLatLng());
+
+ if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort();
+ delete endpoint.geocodeRequest;
+
+ setLatLng(latlng);
+ setInputValueFromLatLng(latlng);
+ endpoint.value = input.val();
+ if (e.type === "dragend") getReverseGeocode();