Meshtastic-Apple/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift

253 lines
9.4 KiB
Swift
Raw Normal View History

2024-03-23 09:01:44 -07:00
//
// MeshMapContent.swift
// Meshtastic
//
// Created by Garth Vander Houwen on 3/17/24.
//
import SwiftUI
import MapKit
2025-07-22 00:48:50 +00:00
import CoreLocation
import OSLog
2024-03-23 09:01:44 -07:00
2025-07-16 02:45:17 +00:00
struct IdentifiableOverlay: Identifiable {
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
let overlay: MKOverlay
var id: ObjectIdentifier { ObjectIdentifier(overlay as AnyObject) }
2025-07-16 02:45:17 +00:00
}
struct ReducedPrecisionMapCircleKey: Hashable {
let latitudeI: Int32
let longitudeI: Int32
let precisionBits: Int32
}
2024-03-23 09:01:44 -07:00
struct MeshMapContent: MapContent {
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2024-03-23 09:01:44 -07:00
/// Parameters
@Binding var showUserLocation: Bool
@AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false
@AppStorage("meshMapShowRouteLines") private var showRouteLines = false
@AppStorage("enableMapConvexHull") private var showConvexHull = false
2025-05-24 00:19:00 -07:00
@AppStorage("enableMapShowFavorites") private var showFavorites = false
2024-03-23 09:01:44 -07:00
@Binding var showTraffic: Bool
@Binding var showPointsOfInterest: Bool
@Binding var selectedMapLayer: MapLayer
// Map Configuration
@Binding var selectedPosition: PositionEntity?
2025-05-05 17:21:08 -07:00
@AppStorage("enableMapWaypoints") private var showWaypoints = true
2024-03-23 09:01:44 -07:00
@Binding var selectedWaypoint: WaypointEntity?
2025-07-21 21:42:36 +00:00
// Map overlays
@AppStorage("mapOverlaysEnabled") private var showMapOverlays = false
@Binding var enabledOverlayConfigs: Set<UUID>
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2024-03-25 15:21:38 -07:00
@FetchRequest(fetchRequest: PositionEntity.allPositionsFetchRequest(), animation: .easeIn)
var positions: FetchedResults<PositionEntity>
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2024-03-25 15:21:38 -07:00
@FetchRequest(fetchRequest: WaypointEntity.allWaypointssFetchRequest(), animation: .none)
var waypoints: FetchedResults<WaypointEntity>
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2024-03-25 19:20:36 -07:00
@FetchRequest(sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)],
predicate: NSPredicate(format: "enabled == true", ""), animation: .none)
private var routes: FetchedResults<RouteEntity>
2024-03-23 09:01:44 -07:00
@MapContentBuilder
var positionAnnotations: some MapContent {
ForEach(positions, id: \.id) { position in
/// Apply favorites filter and don't show ignored nodes
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
if (!showFavorites || (position.nodePosition?.favorite == true)) && !(position.nodePosition?.ignored == true) {
let coordinateForNodePin: CLLocationCoordinate2D = if position.isPreciseLocation {
// Precise location: place node pin at actual location.
position.coordinate
} else {
// Imprecise location: fuzz slightly so overlapping nodes are visible and clickable at highest zoom levels.
position.fuzzedCoordinate
}
2025-10-20 11:33:58 -07:00
if 12...15 ~= position.precisionBits || position.precisionBits == 32 {
let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0))
let positionName = position.nodePosition?.user?.longName ?? "?"
2025-10-20 11:33:58 -07:00
// Use a hash of the position ID to stagger animation delays for each node, preventing synchronized animations and improving visual distinction.
let calculatedDelay = Double(position.id.hashValue % 100) / 100.0 * 0.5
2025-10-21 06:28:33 -07:00
Annotation(positionName, coordinate: coordinateForNodePin) {
2025-10-20 11:33:58 -07:00
LazyVStack {
AnimatedNodePin(
nodeColor: nodeColor,
shortName: position.nodePosition?.user?.shortName,
hasDetectionSensorMetrics: position.nodePosition?.hasDetectionSensorMetrics ?? false,
isOnline: position.nodePosition?.isOnline ?? false,
calculatedDelay: calculatedDelay
)
}
.highPriorityGesture(TapGesture().onEnded { _ in
selectedPosition = (selectedPosition == position ? nil : position)
})
2024-03-23 09:01:44 -07:00
}
}
}
}
2025-05-23 20:53:31 -07:00
}
private var reducedPrecisionCircleItems: [(nodeNum: Int64, circleKey: ReducedPrecisionMapCircleKey)] {
// Precompute *unique* reduced-precision circles so we don't have to redraw tons of identical (center, radius) circles in dense map areas. (Since they're all transparent, this causes severe FPS drop when zoomed into areas where there are a ton of overlapping circles.)
var lowestNumForKey: [ReducedPrecisionMapCircleKey: Int64] = [:]
// Populate a dict where the key is (lat, lon, bits) and the value is the *lowest* node.num seen for that key.
// That lowest node.num value is used to create a stable color for the MapCircle and stable id for ForEach.
for position in positions {
// Same filter criteria as positionAnnotations:
if (!showFavorites || (position.nodePosition?.favorite == true)) && !(position.nodePosition?.ignored == true) {
if 12...15 ~= position.precisionBits {
let nodeNum = position.nodePosition?.num ?? 0
let key = ReducedPrecisionMapCircleKey(latitudeI: position.latitudeI, longitudeI: position.longitudeI, precisionBits: position.precisionBits)
if let existing = lowestNumForKey[key] {
if nodeNum < existing { lowestNumForKey[key] = nodeNum }
} else {
lowestNumForKey[key] = nodeNum
}
}
}
}
// Sort by nodeNum just to keep draw order stable.
return lowestNumForKey.map { ($0.value, $0.key) }.sorted { $0.nodeNum < $1.nodeNum }
}
@MapContentBuilder
var reducedPrecisionMapCircles: some MapContent {
ForEach(reducedPrecisionCircleItems, id: \.nodeNum) { item in
let circleKey = item.circleKey
let nodeNum = item.nodeNum
let radius = PositionPrecision(rawValue: Int(circleKey.precisionBits))?.precisionMeters ?? 0
if radius > 0.0 {
let center = CLLocationCoordinate2D(latitude: Double(circleKey.latitudeI) / 1e7, longitude: Double(circleKey.longitudeI) / 1e7)
let nodeColor = UIColor(hex: UInt32(nodeNum))
MapCircle(center: center, radius: radius)
.foregroundStyle(Color(nodeColor).opacity(0.25))
.stroke(.white, lineWidth: 1)
}
}
}
@MapContentBuilder
var routeAnnotations: some MapContent {
ForEach(routes) { route in
if let routeLocations = route.locations, let locations = Array(routeLocations) as? [LocationEntity] {
let routeCoords = locations.compactMap {(loc) -> CLLocationCoordinate2D in
2025-01-21 09:19:14 -08:00
return loc.locationCoordinate ?? LocationsHandler.DefaultLocation
}
Annotation(String(localized: "Start"), coordinate: routeCoords.first ?? LocationsHandler.DefaultLocation) {
2024-03-23 09:01:44 -07:00
ZStack {
Circle()
.fill(Color(.green))
.strokeBorder(.white, lineWidth: 3)
.frame(width: 15, height: 15)
}
}
.annotationTitles(.automatic)
Annotation(String(localized: "Finish ", comment: "Space at the end has been added to not interfere with translations for 'Finish' in RouteRecorder"), coordinate: routeCoords.last ?? LocationsHandler.DefaultLocation) {
2024-03-23 09:01:44 -07:00
ZStack {
Circle()
.fill(Color(.black))
.strokeBorder(.white, lineWidth: 3)
.frame(width: 15, height: 15)
}
}
.annotationTitles(.automatic)
let solid = StrokeStyle(
lineWidth: 3,
lineCap: .round, lineJoin: .round
)
MapPolyline(coordinates: routeCoords)
.stroke(Color(UIColor(hex: UInt32(route.color))), style: solid)
}
}
}
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
@MapContentBuilder
var waypointAnnotations: some MapContent {
if waypoints.count > 0, showWaypoints, let waypoints = Array(waypoints) as? [WaypointEntity] {
ForEach(waypoints, id: \.self) { waypoint in
2024-03-23 09:01:44 -07:00
Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) {
LazyVStack {
2024-03-25 15:21:38 -07:00
ZStack {
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 40)
2025-05-05 22:06:08 -07:00
.highPriorityGesture(TapGesture().onEnded { _ in
2024-03-25 15:21:38 -07:00
selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint)
})
}
2024-03-23 09:01:44 -07:00
}
}
}
}
}
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
@MapContentBuilder
var meshMap: some MapContent {
let loraNodes = positions.filter { $0.nodePosition?.viaMqtt ?? true == false }
let loraCoords = Array(loraNodes).compactMap({(position) -> CLLocationCoordinate2D in
return position.nodeCoordinate ?? LocationsHandler.DefaultLocation
})
/// Convex Hull
if showConvexHull {
if loraCoords.count > 0 {
let hull = loraCoords.getConvexHull()
MapPolygon(coordinates: hull)
.stroke(.blue, lineWidth: 3)
.foregroundStyle(.indigo.opacity(0.4))
}
}
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2025-07-22 00:48:50 +00:00
/// GeoJSON Overlays with embedded styling
2025-07-21 21:42:36 +00:00
if showMapOverlays {
2025-07-22 00:48:50 +00:00
overlayContent
}
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2025-07-22 00:48:50 +00:00
positionAnnotations
reducedPrecisionMapCircles
2025-07-22 00:48:50 +00:00
routeAnnotations
waypointAnnotations
}
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2025-07-22 00:48:50 +00:00
var overlayContent: some MapContent {
// Get all features but filter by enabled configs
let allStyledFeatures = GeoJSONOverlayManager.shared.loadStyledFeaturesForConfigs(enabledOverlayConfigs)
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2025-07-22 00:48:50 +00:00
return Group {
ForEach(0..<allStyledFeatures.count, id: \.self) { index in
let styledFeature = allStyledFeatures[index]
2025-07-22 00:48:50 +00:00
let feature = styledFeature.feature
let geometryType = feature.geometry.type
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2025-07-22 00:48:50 +00:00
if geometryType == "Point" {
if let coordinate = feature.geometry.coordinates.toCoordinate() {
2025-07-22 06:40:43 +00:00
Annotation(feature.name, coordinate: coordinate) {
2025-07-22 00:48:50 +00:00
Circle()
.fill(styledFeature.fillColor)
.stroke(styledFeature.strokeColor, style: styledFeature.strokeStyle)
.frame(width: feature.markerRadius * 2, height: feature.markerRadius * 2)
}
2025-07-23 20:24:55 +00:00
.annotationTitles(.automatic)
2025-07-22 00:48:50 +00:00
.annotationSubtitles(.hidden)
}
} else if geometryType == "LineString" {
if let overlay = styledFeature.createOverlay() as? MKPolyline {
MapPolyline(overlay)
.stroke(styledFeature.strokeColor, style: styledFeature.strokeStyle)
}
} else if geometryType == "Polygon" {
if let overlay = styledFeature.createOverlay() as? MKPolygon {
MapPolygon(overlay)
.foregroundStyle(styledFeature.fillColor)
.stroke(styledFeature.strokeColor, style: styledFeature.strokeStyle)
2025-07-18 01:28:21 +00:00
}
2025-07-16 02:45:17 +00:00
}
}
}
}
2.7.3 Working Changes (#1404) * Remove non functional module override button * Remove stale keys * Onboarding and lora config bug fixes * Add Annotations view and try and simplify online annimations to improve performance. * Bump version * Fix proto bug * Don't show ignored nodes on the mesh map * More node annotation animation improvements * Ham * Remove liquid glass form icon * Update MQTT config logic * Liquid glass chirpy and ham on the watch * Use Hops away value for DM's (#1409) * Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to. * Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Icons * 🐰 * DataDog action logging (#1411) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update location usage details * Good doggo (#1414) * DataDog action logging * Filter version hash --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Helpers/LocationsHandler.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00
2024-03-23 09:01:44 -07:00
@MapContentBuilder
var body: some MapContent {
2024-03-24 23:13:35 -07:00
meshMap
2024-03-23 09:01:44 -07:00
}
}