mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Basic map is working. ABout to start on offline
This commit is contained in:
parent
6d90211ab5
commit
b492113c02
3 changed files with 19 additions and 1 deletions
|
|
@ -41,6 +41,8 @@ public struct MapView: UIViewRepresentable {
|
|||
@FetchRequest(sortDescriptors: [NSSortDescriptor(key: "lastHeard", ascending: false)], animation: .default)
|
||||
private var locationNodes: FetchedResults<NodeInfoEntity>
|
||||
|
||||
//@State private var locationNodes: [NodeInfoEntity]
|
||||
|
||||
public init(
|
||||
//region: Binding<MKCoordinateRegion> = .constant(MKCoordinateRegion()),
|
||||
customMapOverlay: CustomMapOverlay? = nil,
|
||||
|
|
@ -95,7 +97,7 @@ public struct MapView: UIViewRepresentable {
|
|||
|
||||
//self.annotations = annotations
|
||||
|
||||
//self.locationNodes = locationNodes
|
||||
self.locationNodes = locationNodes
|
||||
|
||||
self.overlays = overlays
|
||||
|
||||
|
|
@ -106,9 +108,24 @@ public struct MapView: UIViewRepresentable {
|
|||
mapView.delegate = context.coordinator
|
||||
mapView.register(PositionAnnotationView.self, forAnnotationViewWithReuseIdentifier: NSStringFromClass(PositionAnnotationView.self))
|
||||
|
||||
Timer.scheduledTimer(withTimeInterval: 10, repeats: true) { timer in
|
||||
for node in self.locationNodes {
|
||||
// try and get the last position
|
||||
if (node.positions?.count ?? 0) > 0 && (node.positions!.lastObject as! PositionEntity).coordinate != nil {
|
||||
let annotation = PositionAnnotation()
|
||||
annotation.coordinate = (node.positions!.lastObject as! PositionEntity).coordinate!
|
||||
annotation.title = node.user?.longName ?? "Unknown"
|
||||
annotation.shortName = node.user?.shortName?.uppercased() ?? "???"
|
||||
|
||||
mapView.addAnnotation(annotation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mapView
|
||||
}
|
||||
|
||||
|
||||
public func updateUIView(_ mapView: MKMapView, context: Context) {
|
||||
|
||||
//if self.userTrackingMode == MKUserTrackingMode.none && (mapView.region.center.latitude != self.region.center.latitude || mapView.region.center.longitude != self.region.center.longitude) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue