Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocatableMap only ever shows one Locatable #734

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/Site/Music/UI/LocatableMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import MapKit
import SwiftUI

struct LocatableMap<T>: View where T: Locatable, T: Equatable {
let locations: [T]
let location: T

var body: some View {
Map(
mapRect: .constant(locations.paddedRect),
mapRect: .constant(location.paddedRect),
interactionModes: MapInteractionModes(),
annotationItems: locations
annotationItems: [location]
) { item in
MapMarker(coordinate: item.center)
}
Expand All @@ -31,5 +31,5 @@ struct LocatableMap<T>: View where T: Locatable, T: Equatable {
var radius: CLLocationDistance { 100.0 }
}

return LocatableMap(locations: [PreviewLocation()])
return LocatableMap(location: PreviewLocation())
}
2 changes: 1 addition & 1 deletion Sources/Site/Music/UI/LocationMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct LocationMap: View {
var body: some View {
ZStack {
if let placemark {
LocatableMap(locations: [placemark])
LocatableMap(location: placemark)
.onTapGesture {
MKMapItem(placemark: MKPlacemark(placemark: placemark)).openInMaps()
}
Expand Down
8 changes: 0 additions & 8 deletions Sources/Site/Utility/Locatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ extension Locatable {
return MKMapRect(origin: MKMapPoint(center), size: MKMapSize(width: 1, height: 1)).insetBy(
dx: -mapPointOffset, dy: -mapPointOffset)
}
}

extension Sequence where Element: Locatable {
var rect: MKMapRect {
var union = MKMapRect.null
self.forEach { union = union.union($0.rect) }
return union
}

var paddedRect: MKMapRect {
let locatableRect = self.rect
Expand Down