Add distance from current location to annotation detail

This commit is contained in:
Garth Vander Houwen 2023-03-04 16:33:28 -08:00
parent 8768b658bf
commit b630821f10

View file

@ -242,6 +242,8 @@ struct MapViewSwiftUI: UIViewRepresentable {
} else {
annotationView.glyphImage = UIImage(systemName: "flipphone")
}
let metersAway = positionAnnotation.coordinate.distance(from: LocationHelper.currentLocation)
subtitle.text! += NSLocalizedString("distance", comment: "") + ": \(distanceFormatter.string(fromDistance: Double(metersAway))) \n"
subtitle.text! += positionAnnotation.time?.formatted() ?? "Unknown \n"
subtitle.numberOfLines = 0
annotationView.detailCalloutAccessoryView = subtitle