Geocortex Web comes with default behavior that runs on a map click. The default behavior will identify and display details for results in the nearby area. But what if you want to replace the functionality with your own behavior? This can be accomplished by leveraging Geocortex Workflow and editing the app config.
We will modify the default map on click behavior to buffer the click geometry by a user provided distance and create a graphic which visualizes this buffer.
- Follow along by setting up the Geocortex Web SDK and editing the minimal layout and app config provided.
- Check out the deployment instructions to learn about how to deploy layout and app config to an application.
Start the Geocortex Web SDK with the following layout and app JSON. You should see a simple application with one layer, Fire Hydrants, which has a related table Fire Hydrant Surveys.
Try clicking the map. It should return results for the point you clicked in the results list.
- App Config
The first thing we need to do is override the default map click behavior. We can do this by editing the default behavior for the
<map/> component in the app config. The default behavior for the map's
onClick event is a command chain that runs
geometry.add-pixel-tolerance and then
tasks.identify, and finally,
First, we are going to replace the command chain with a
workflow.run command that replicates this behavior.
- Open up Geocortex Workflow Designer and create and save a new workflow.
- Add an "Alert" activity as a test.
- Copy the ID of the the workflow from the URL
- Add the workflow as an app item to your app config.
- Next, configure the
onClickproperty of the Map Component in the app config to run the workflow.
- Run the app and test your workflow. You should see your alert pop up when you try to click on the map.
- Open up your workflow in the Geocortex Workflow Designer again. The default behavior we just overrode can be recreated with the use of RunCommand and RunOperation activities.
tasks.identifyare operations, so they need RunOperation activities, and
results.display-detailsis a command so it needs a RunCommand Activity. Chain these three activities together, passing the workflow context to
geometry.add-pixel-toleranceand then passing the output of that operation to
tasks.identify, and finally passing the output of
- Save the workflow and reload the application. Test the map click functionality and ensure it works as it originally did.
At this point, you can choose to extend the map click behavior with Geocortex Workflow in whatever way is appropriate for your tutorial. You could execute a different "identify" for external results and add them to the set of results displayed, or zoom the map to a specific orientation and scale, or display a form for the user to fill out with relevant information to that location. For this example, a workflow was created which asks a user for a buffer distance, and creates a graphic showing the buffer around the click location.