So i have multiple markers on a map and the markers have a popup. On this popup screen i would like the status of the marker to be shown using a label. This label should turn red if the tag is offline and green if the tag is online.
I made a custom property called ‘Selected_tag_path_value’. That didnt work because it was not recognizing what tag was being selected at the same time as the status of that tag. The status value is either a 1 or 0 .
So I have a view with a table on it that returns the data of a specific tag depending on what marker is clicked.
I then have a status label on the same view that I want to change colour depending on what the status of the marker that I have clicked is.
So that popup is made my configuring events on the map and writing a script like this
marker = next(m for m in self.props.layers.ui.marker if m['name'] == event.name)
self.session.custom.selected_tag_path = marker['tagpath']
But what I want is for the label to instead of showing data, I want it to show a colour depending on whether the tag is online or offline for the same tag thats data is being displayed on the table.
On the view that you are using as a popup, create 2 parameters: tagPath and markerStatus (or however you want to name them). Then in the event that fires when the marker is clicked, open the popup and pass those parameters to it (just like in @nminchin example above). In the popup, bind the table data to the parameter rather than the session prop, and bind the label color to the status parameter.
So you're already passing in the tag path to the tag into the popup and it looks like you've already bound the label.props.text to an indirect tag binding using the view.params.tagPath (or whatever you've called it), you just need to also bind the label.props.style.backgroundColor to the label.props.text property and use a map transform with your colours in it.
If I were doing this, I would use style classes for the colour so that I can define the colours globally to use everywhere instead of using magic colours that are horrible to maintain and incredibly time-consuming