In certain situations, you may want to modify the look of your app at startup based on URL parameters. This would allow you to offer different user experiences of the same app just by changing part of the URL. For example, if you have an app that shows outdoor recreational areas in public parks, you may want an elevation overview map and legend to load for users accessing the app from a "View hiking trails" hyperlink on your website, but display a panel with campground rules if someone accesses the app via a "Camp here" hyperlink.
This is possible in VertiGIS Studio Web with the use of Launch Link Workflows.
How to set it up
The configuration requires some planning and use of both VertiGIS Studio Web Designer and VertiGIS Studio Workflow Designer. Before you begin, please make sure your Web app is fully set up, and includes any components you would like to show or hide based on URL parameters.
This article is broken down into the following sections:
Gather information from the Web app
If you want to show or hide entire components, such as the legend, you will need to note down the Model URI or Layout ID of each one. To do so:
- Open your app in VertiGIS Studio Web Designer.
- Select the desired component in the Components list.
- Click the gear icon in the upper left of its settings.
- Copy down either the Model URI or the Layout ID.
Build the workflow
Though the workflow can be made to be much more complex, here are the basics for activating or deactivating app components based on URL parameters:
- Create a new blank workflow in VertiGIS Studio Workflow Designer.
- Add a Get Workflow Inputs activity. This will get the inputs from the URL parameters.
- Add a Delay activity. This is important because it ensures the components in your app have had time to load before you try to activate or deactivate then. You may need to adjust the duration of the delay based on your app. A good starting point is 1000 (milliseconds).
- Add a Switch activity.
- Now, choose a name for your URL parameter. For example, if you plan on having a different layout for camping and hiking, you might set the name of the URL parameter to "parkUse". Make note of this name, as you will need to use it later.
- Set the input for the Switch activity to the output of your Get Workflow Inputs activity followed by the URL parameter name you chose. For example:
=$getWorkflowInputs1.inputs.parkUse
- Set the default path of the Switch activity to an Exit activity. This ensures that your app loads the standard layout you've built in VertiGIS Studio Web Designer if no URL parameters are supplied.
- Add a Run Command activity for each component you would like to activate/deactivate, but do not connect them to anything yet. Set the inputs as follows:
- Command Name: ui.activate or ui.deactivate
- Command Parameter: Model URI or Layout ID of the component
- Connect the Run Command activities to each other based on the layout you want displayed. For example, all Run Command activities that activate or deactivate components for the "hiking" view should be connected, and all Run Command activities that activate or deactivate components for the "camping" view should be connected.
- Connect a path from the Switch activity to each separate "view". Set the name for each path based on what you would like the URL parameter to be. For example, one might be called "hiking" and another called "camping".
- Save the workflow.
Add the workflow to your app
Once the workflow is configured, you'll need to set it up so it runs when the app is launched with a certain URL.
- Open your app in VertiGIS Studio Web Designer.
- Click on the Services tab.
- Select the Launch Link Workflows section.
- Click the Add Workflow button and select the workflow you just created.
- Save your app.
- In the left toolbar, select Deploy.
- Use the three dots next to your app to open its menu and select Get Links.
- Under "Workflow to run (optional)", select your recently added workflow.
- Copy the Launch URL.
- Paste it into into your address bar, but don't navigate to it yet.
- Add the parameter name and value as a key-value pair in the "workflowParams" section at the end of the URL. For example:
workflowParams={"parkUse":"hiking"}
- Navigate to the address. Your app should load the desired initial view.
Demo
Try it out with this demo app:
- Camping URL: https://apps.vertigisstudio.com/web/?app=d19d04834fa94971b999290a6bda1bdd&workflow=1e7e2be2-ac0f-4f4a-9826-d15b05057259&workflowParams={"parkUse":"camping"}
- Hiking URL: https://apps.vertigisstudio.com/web/?app=d19d04834fa94971b999290a6bda1bdd&workflow=1e7e2be2-ac0f-4f4a-9826-d15b05057259&workflowParams={"parkUse":"hiking"}
Comments
0 comments
Article is closed for comments.