Post

Replies

Boosts

Views

Activity

swiftUI, MapKit, Variable in Map Issue
**Hi, hopefully you can help me with this swiftUI code? I have created a Map App which will show a route via a ManPolyLine (see the code). Whilst I can print the route via the (in the code below) var _ = print("ROUTE = (route.steps.map { $0.instructions }.filter { !$0.isEmpty })") I CANNOT create a variable for the route it prints? I need to do this so I can create a .sheet (which is shown), but cannot Access a Variable to List the route details! Help would be most appreciated, TIA (The pertinent part of the code below)** =========================================== @State private var route: MKRoute? @State private var myRoute: [String] = [] @State private var selectedResult: MKMapItem? @State private var position: MapCameraPosition = .automatic Map(position: $position, selection: $selectedResult) { ForEach(searchResults, id: \.self) { result in Marker(item: result) } .annotationTitles(.hidden) UserAnnotation() if let route { MapPolyline(route) .stroke(.blue, lineWidth: 5) var myRoute = route.steps.map { $0.instructions }.filter { !$0.isEmpty } var _ = print("ROUTE = \(route.steps.map { $0.instructions }.filter { !$0.isEmpty })") var _ = print("COUNT = \(myRoute.count)") } } ===========================================
1
0
443
Feb ’24
SwiftUICharts in swiftUI
Using an Example of SwiftUICharts, I have used the following, to create a line chart: LineView(data: [8,23.5,54.8,32,12,37,7,23,43]) And it works very nicely:-) However I want to plot x,y rather than just y values I have tried LineView(data: [1,2,3,4,5,6,7,8,9], [8,23.5,54.8,32,12,37,7,23,43]) (With and without the comma which separates the 2 bracketed “terms”) And LineView(data: [(1,8),(2,23.5),(3,54.8),(4,32),(5,12),(6,37),(7,7),(8,23),(9,43)]) All gave errors Any idea how I should present the data to obtain the x,y line graph? TIA, Phil.
0
0
669
Aug ’20