MapKit 図形をかく
Rectangle (Polygon) を書く
swift
@State private var bounds: [[CLLocationCoordinate2D]] = []
@State private var boundLabels: [String] = []
ForEach(0..<bounds.count, id: \.self) { i in
MapPolygon(coordinates: bounds[i])
.foregroundStyle(.clear)
.stroke(.red, lineWidth: 3)
}
ForEach(0..<bounds.count, id: \.self) { i in
Annotation(boundLabels[i], coordinate: bounds[i][1], content: {})
}
// の元ネタ
[
CLLocationCoordinate2D(latitude: yMin, longitude: xMin),
CLLocationCoordinate2D(latitude: yMin, longitude: xMax),
CLLocationCoordinate2D(latitude: yMax, longitude: xMax),
CLLocationCoordinate2D(latitude: yMax, longitude: xMin),
]