Using Xcode 15.0 beta 4
I have MapCoordinate
struct:
private struct MapCoordinate: Equatable {
let location: Location
let latitude: Double
let longitude: Double
var coordinate: CLLocationCoordinate2D {
return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
}
init?(location: Location) {
guard let latitude = location.latitude,
let longitude = location.longitude else {
return nil
}
self.location = location
self.latitude = latitude
self.longitude = longitude
}
}
mapCoordinate
and radius
state variables:
@State private var mapCoordinate: MapCoordinate?
@State private var radius: CLLocationDistance
And a mapView
:
@ViewBuilder var mapView: some View {
Map {
if let mapCoordinate {
let annotationTitle = radius.toMeasurement(unit: .meters, convertedTo: .kilometers)
Annotation(annotationTitle, coordinate: mapCoordinate.coordinate) {
Image(systemImage: .mapPinEllipse)
.fontWeight(.semibold)
}
MapCircle(center: mapCoordinate.coordinate, radius: radius)
.foregroundStyle(.teal.opacity(circleOpacity))
.stroke(.teal, lineWidth: circleStrokeLineWidth)
}
}
.mapStyle(.standard(elevation: .realistic))
.animation(.easeInOut, value: mapCoordinate)
}
When updating mapCoordinate
the Annotation
will animate correctly to the new coordinates, but the MapCircle
will not update or change scale for neither mapCoordinate
or radius
changes.
Ideas?