Hello, I am trying to refresh my mapview with my latest annotations from using a picker which returns a range of dates. However this routine I am using only seems to be triggered once when the program starts. When I make a selection from the picker there is no update to the map. Any help would be appreciated. Thank you
@State var myPick: Int = 0
@State var selectedWeek = "Today"
var mySpan = ["Today", "1Week", "2Weeks", "3Weeks", "4Weeks"]
var body: some View {
NavigationView {
VStack {
MyMapView()
.edgesIgnoringSafeArea(.all)
Picker(selection: $myPick, label: Text("")) {
ForEach(0..<mySpan.count) {index in
Text(self.mySpan[index]).tag(index)
}}
.pickerStyle(SegmentedPickerStyle())
When I go to the view below the value of myPick stays the same as set in the @State declaration (0)
for userLocation in userLocations {
let myValue = myMap.myPick
print(myValue) ****This value is always zero even though I am changing picker selection.
print(userLocation.date! as Any)
print(Span(increment: myValue))