More on IF - is there an ELSE IF that goes with this
So now that I understand the syntax for the IF conditional, I now need to test a drop down list with 10 or so options. Would be nice to have an ELSE IF action option, but I'm not seeing it...?
-
Hello Mike,
Currently, there is only an If activity. You can use chained If statements to achieve Else/If behaviour.
Thanks, Stefan
0 -
That's what I figured. I'm trying to do a simple layer picker, so I'm testing the drop down list, and I figured I would need to use a Set Layer Visibility action, but I'm not getting that to work. First off, will this work for a layer within? a folder where I've set only one layer to be visible at a time? If not, will I need to manually turn off all the layers and then turn on the one I want? When it asks for the Layer ID - is that what I find in Manager on the Details tab? For the Visibility setting, do I just type in "true"?
0 -
If you are using GVH, the Layer ID should correspond to the ID in the REST API. The documentation currently is missing information on how to set these values, which will included in the future. If you are using WAB, you'll use the Get Layer activity with the name of the layer within the web map, then set the input to the Set Layer Visibility as the output of the Get Layer.
The behaviour of setting the visibility on a layer or folder will match the behaviour of enabling or disabling boxes or radiobuttons within GVH, depending on the folder settings. Depending on your use case, you may need to manually turn off all the layers.
Yes, the visibility will be true to make a layer visible.
0 -
I have my services directory disabled - is there another way to see rest end point? I'm doing this in GVH. Looking at the site?.xml, the connection string ends with /PoliceIncidentsFeatures/FeatureServer/1 and later in that line, it has ID="48"
0 -
P.S. don't forget the switch activity... If its the same value you're testing, easier then a whole bunch of if/elses...
https://docs.geocortex.com/workflow/latest/help/Default.htm#wf5/help/activities/switch.htm
0 -
Also, I guess I should ask this before going much further - are there activities to control layer visualization (heat map and feature clustering)??
0 -
Ryan, the switch activity sounds like it could work, but the documentation is a bit skimpy... I'm doing a change event and the first thing is a Get Form Element Property to get the value of my drop down list. So for the switch, I'm using =$getFormElementProperty2.value for the input. At this point it becomes unclear. How do a set up the outputs/branches? Does it somehow just take all of the options in the drop down list??
0 -
I think you can just use:
=$form1.state.yournamedDDL.value
but your works too...
set the value of the switch to one of those...
to get the hang of it just add a couple Log activities and connect the lines to switch...
The first one will be designated 'default' which is no match found... the next should say case1, case2 etc... Click the 'case#' label, and you can change the value to the values in your dropdown...
Switch value 'string' compares to the case-value, where equal it'll go down that path, else will go to the 'default' branch.
0 -
So did get the switch activity to work - was confusing on where to "set the value of the switch" but discovered after some trial and error that once an activity as connected to the switch, it names first as "Default" then next one as "Case1", etc. These can then be renamed to be the value set on the drop down list. I also got the visibility to work. Even though I had set the folder to only allow one layer to be visible at a time, setting a new layer to be visible caused both the old and new layer to be turned on. I changed the change event to first turn off all the layers, then use the switch to turn on the one chosen.
Still looking for activities to change Visualization between Heat Map and Feature Clustering...?
0 -
Well, almost have the layer visibility working - I'm correctly changing the visibility, but it is not getting reflected on the layer list if open that up...it is still showing the original checked layer.?
0 -
Hello Mike,
I'm not aware of any methods to switch between these visualization options, though you could create a new idea in the Ideas section. Were you able to achieve this using the previous version of workflows?
Thanks, Stefan
0 -
No, I wasn't a huge fan of the old workflow. The project that I am currently working on seemed like a good way to learn GW5. This is my site:
https://maps.srcity.org/Html5Viewer/Index.html?viewer=PoliceViewer
I have a GW5 on the I want to menu. I'm trying to create a simple site to show crime data. I would like the user to be presented with this form when the site loads. I currently have the layer picker working. I have a radio group on the form that lets the user choose between Heat Maps and Feature Clustering, and at this point, I'm just using this to control the visibility of a couple of number sliders. I can just give up on having the user be able to switch to Feature Clustering, or to have the ability to control the Heat Map Intensity, but I would really like to have them... Any ideas would be hugely welcome!?
0 -
For anyone still looking at a possible solution for if/else, consider a ternary (?:) operation. I did this when trying to query against a different service URL depending on the user's choice so I could keep my workflow a little more tidy. See example below of a chained one based on radio button values that I put into a Create Value tool.
=($Form1.state.radioGroup1.value === "valOne") ? $oneURL.result : ($Form1.state.radioGroup1.value === "valTwo") ? $twoURL.result : ($Form1.state.radioGroup1.value === "valThree") ? $threeURL : $fourURL
I couldn't find what I was looking for so hopefully this will help someone, even if it's a year later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator
1
Vous devez vous connecter pour laisser un commentaire.
Commentaires
13 commentaires