mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #354 from meshtastic/waypoint_form_bugfixes
Fix map line crash
This commit is contained in:
commit
eaa5e8f2a3
3 changed files with 42 additions and 9 deletions
|
|
@ -152,12 +152,27 @@ enum LocationUpdateInterval: Int, CaseIterable, Identifiable {
|
|||
}
|
||||
enum MapTileServerLinks: Int, CaseIterable, Identifiable {
|
||||
|
||||
case openStreetMaps
|
||||
case wikimedia
|
||||
case nationalMap
|
||||
case none = 0
|
||||
case openStreetMaps = 1
|
||||
case wikimedia = 2
|
||||
case nationalMap = 3
|
||||
var id: Int { self.rawValue }
|
||||
var description: String {
|
||||
switch self {
|
||||
case .none:
|
||||
return "Please Select"
|
||||
case .wikimedia:
|
||||
return "Wikimedia"
|
||||
case .openStreetMaps:
|
||||
return "Open Street Maps"
|
||||
case .nationalMap:
|
||||
return "US National Map"
|
||||
}
|
||||
}
|
||||
var tileUrl: String {
|
||||
switch self {
|
||||
case .none:
|
||||
return ""
|
||||
case .wikimedia:
|
||||
return "https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png"
|
||||
case .openStreetMaps:
|
||||
|
|
@ -168,6 +183,8 @@ enum MapTileServerLinks: Int, CaseIterable, Identifiable {
|
|||
}
|
||||
var zoomRange: [Int] {
|
||||
switch self {
|
||||
case .none:
|
||||
return [Int](0...1)
|
||||
case .wikimedia:
|
||||
return [Int](0...24)
|
||||
case .openStreetMaps:
|
||||
|
|
|
|||
|
|
@ -160,10 +160,10 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
var lineIndex = 0
|
||||
for position in latest {
|
||||
|
||||
let nodePositions = positions.filter { $0.nodePosition?.num ?? 0 == position.nodePosition?.num ?? -1 }
|
||||
let lineCoords = nodePositions.map ({
|
||||
let nodePositions = positions.filter { $0.nodeCoordinate != nil && $0.nodePosition?.num ?? 0 == position.nodePosition?.num ?? -1 }
|
||||
let lineCoords = nodePositions.compactMap ({
|
||||
(position) -> CLLocationCoordinate2D in
|
||||
return position.nodeCoordinate!
|
||||
return position.nodeCoordinate ?? LocationHelper.DefaultLocation
|
||||
})
|
||||
let polyline = MKPolyline(coordinates: lineCoords, count: nodePositions.count)
|
||||
polyline.title = "\(String(position.nodePosition?.num ?? 0))"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ struct NodeMap: View {
|
|||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
|
||||
@AppStorage("meshMapType") private var meshMapType = 0
|
||||
@State var meshMapType: Int = UserDefaults.mapType
|
||||
@State var enableMapRecentering: Bool = UserDefaults.enableMapRecentering
|
||||
@State var enableMapRouteLines: Bool = UserDefaults.enableMapRouteLines
|
||||
@State var enableMapNodeHistoryPins: Bool = UserDefaults.enableMapNodeHistoryPins
|
||||
|
|
@ -32,8 +32,9 @@ struct NodeMap: View {
|
|||
), animation: .none)
|
||||
private var waypoints: FetchedResults<WaypointEntity>
|
||||
|
||||
@State private var mapType: MKMapType = .standard
|
||||
@State var mapType: MKMapType = .standard
|
||||
@State var selectedTracking: UserTrackingModes = .none
|
||||
@State var selectedTileServer: MapTileServerLinks = .wikimedia
|
||||
@State var isPresentingInfoSheet: Bool = false
|
||||
|
||||
@State var waypointCoordinate: WaypointCoordinate?
|
||||
|
|
@ -137,8 +138,23 @@ struct NodeMap: View {
|
|||
self.enableOfflineMaps.toggle()
|
||||
UserDefaults.enableOfflineMaps = self.enableOfflineMaps
|
||||
}
|
||||
Text("If you have shared a MBTiles file with meshtastic it will be loaded.")
|
||||
.font(.caption)
|
||||
.foregroundColor(.gray)
|
||||
|
||||
if UserDefaults.enableOfflineMaps {
|
||||
HStack {
|
||||
// Picker("Tile Servers", selection: $selectedTileServer) {
|
||||
// ForEach(MapTileServerLinks.allCases) { ts in
|
||||
// Text(ts.description)
|
||||
// .tag(ts.id)
|
||||
// }
|
||||
// }
|
||||
// .pickerStyle(.menu)
|
||||
// .onChange(of: (selectedTileServer)) { newTileServer in
|
||||
//
|
||||
// mapTileServer = selectedTileServer.tileUrl
|
||||
// }
|
||||
|
||||
Label("Tile Server", systemImage: "square.grid.3x2")
|
||||
TextField(
|
||||
|
|
@ -147,7 +163,7 @@ struct NodeMap: View {
|
|||
axis: .vertical
|
||||
)
|
||||
.foregroundColor(.gray)
|
||||
.font(.caption2)
|
||||
.font(.caption)
|
||||
.onChange(of: (mapTileServer)) { newMapTileServer in
|
||||
UserDefaults.mapTileServer = newMapTileServer
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue