import CoreLocation

// 함수를 통해 현재 위치에서 마커의 거리를 계산
func calculateDistanceFromCurrentLocation(to markerLocation: CLLocationCoordinate2D) {
    guard let currentLocation = locationManager.location else {
        print("Unable to retrieve current location.")
        return
    }

    // 현재 위치
    let currentCLLocation = CLLocation(latitude: currentLocation.latitude, longitude: currentLocation.longitude)
    
    // 마커 위치
    let markerCLLocation = CLLocation(latitude: markerLocation.latitude, longitude: markerLocation.longitude)

    // 거리 계산 (단위: 미터)
    let distance = currentCLLocation.distance(from: markerCLLocation)
    print("Distance from current location to marker: \\(distance) meters")
}

// 예시: 마커의 위치 (위도, 경도)
let markerLocation = CLLocationCoordinate2D(latitude: 37.123456, longitude: 127.987654)

// 거리 계산 함수 호출
calculateDistanceFromCurrentLocation(to: markerLocation)

BaseRealm