mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Center the node detail map on positions, node map on both positions and waypoints
This commit is contained in:
parent
3d1111972c
commit
f59b4a8a86
3 changed files with 14 additions and 2 deletions
|
|
@ -15,6 +15,7 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
let positions: [PositionEntity]
|
||||
let waypoints: [WaypointEntity]
|
||||
let mapViewType: MKMapType
|
||||
let centerOnPositionsOnly: Bool
|
||||
|
||||
// Offline Maps
|
||||
//make this view dependent on the UserDefault that is updated when importing a new map file
|
||||
|
|
@ -27,8 +28,13 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
|
||||
func makeUIView(context: Context) -> MKMapView {
|
||||
// Parameters
|
||||
mapView.fit(annotations: positions, andShow: true)
|
||||
mapView.addAnnotations(waypoints)
|
||||
if centerOnPositionsOnly {
|
||||
mapView.fit(annotations: positions, andShow: true)
|
||||
} else {
|
||||
mapView.addAnnotations(positions)
|
||||
mapView.fitAllAnnotations()
|
||||
}
|
||||
mapView.mapType = mapViewType
|
||||
mapView.setUserTrackingMode(.none, animated: true)
|
||||
// Other MKMapView Settings
|
||||
|
|
|
|||
|
|
@ -52,8 +52,10 @@ struct NodeDetail: View {
|
|||
presentingWaypointForm = true
|
||||
}
|
||||
}, positions: annotations, waypoints: Array(waypoints), mapViewType: mapType,
|
||||
centerOnPositionsOnly: true,
|
||||
customMapOverlay: self.customMapOverlay,
|
||||
overlays: self.overlays
|
||||
|
||||
)
|
||||
VStack {
|
||||
Spacer()
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ struct NodeMap: View {
|
|||
predicate: NSPredicate(format: "time >= %@", Calendar.current.startOfDay(for: Date()) as NSDate), animation: .easeIn)
|
||||
private var positions: FetchedResults<PositionEntity>
|
||||
|
||||
//@FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: false)],
|
||||
// predicate: NSPredicate(format: "expire >= %@", Calendar.current.startOfDay(for: Date()) as NSDate), animation: .easeIn)
|
||||
//private var waypoints: FetchedResults<WaypointEntity>
|
||||
|
||||
@FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: false)], animation: .easeIn)
|
||||
private var waypoints: FetchedResults<WaypointEntity>
|
||||
|
||||
|
|
@ -58,8 +62,8 @@ struct NodeMap: View {
|
|||
} else {
|
||||
presentingWaypointForm = true
|
||||
}
|
||||
|
||||
}, positions: Array(positions), waypoints: Array(waypoints), mapViewType: mapType,
|
||||
centerOnPositionsOnly: false,
|
||||
customMapOverlay: self.customMapOverlay,
|
||||
overlays: self.overlays
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue