mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix map centering bug
This commit is contained in:
parent
a991087bc2
commit
ca302cbcd5
2 changed files with 19 additions and 15 deletions
|
|
@ -47,7 +47,7 @@ class UserSettings: ObservableObject {
|
|||
}
|
||||
@Published var meshMapRecentering: Bool {
|
||||
didSet {
|
||||
UserDefaults.standard.set(meshMapCenteringMode, forKey: "meshMapRecentering")
|
||||
UserDefaults.standard.set(meshMapRecentering, forKey: "meshMapRecentering")
|
||||
UserDefaults.standard.synchronize()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,25 +138,29 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
let annotationCount = waypoints.count + positions.count
|
||||
if annotationCount != mapView.annotations.count {
|
||||
mapView.removeAnnotations(mapView.annotations)
|
||||
let latest = positions.filter { $0.latest == true }
|
||||
mapView.addAnnotations(waypoints)
|
||||
mapView.setUserTrackingMode(userTrackingMode, animated: true)
|
||||
if userTrackingMode != MKUserTrackingMode.none {
|
||||
mapView.showsUserLocation = true
|
||||
} else {
|
||||
|
||||
if userTrackingMode == MKUserTrackingMode.none {
|
||||
mapView.showsUserLocation = false
|
||||
}
|
||||
switch centeringMode {
|
||||
case .allAnnotations:
|
||||
mapView.addAnnotations(positions)
|
||||
if recenter && userTrackingMode == MKUserTrackingMode.none {
|
||||
mapView.fitAllAnnotations()
|
||||
}
|
||||
case .allPositions:
|
||||
if recenter && userTrackingMode == MKUserTrackingMode.none {
|
||||
mapView.fit(annotations: positions, andShow: true)
|
||||
} else {
|
||||
switch centeringMode {
|
||||
case .allAnnotations:
|
||||
mapView.addAnnotations(positions)
|
||||
if recenter && userTrackingMode == MKUserTrackingMode.none {
|
||||
mapView.fitAllAnnotations()
|
||||
}
|
||||
case .allPositions:
|
||||
if recenter && userTrackingMode == MKUserTrackingMode.none {
|
||||
mapView.fit(annotations: positions, andShow: true)
|
||||
} else {
|
||||
mapView.addAnnotations(positions)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Centering Done by tracking mode
|
||||
mapView.addAnnotations(positions)
|
||||
mapView.showsUserLocation = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue