Segmented Picker

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 { 
            Picker(selection: $myPick, label: Text("")) {
                ForEach(0..<mySpan.count) {index in

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(! as Any)
print(Span(increment: myValue))

Taking an action based on a change to a Picker is tricky. I used this approach:

Please do not create random content related thread tags. Thank you. :slight_smile: I exchanged them all with the most appropriate tags for this thread.

1 Like