Show a Callout on the Map with an Activity
Some activities may need access to the map embedded in the Geocortex Mobile Application. The MapProviderBase
class can be injected in an activity and used to access the Map and MapView for the application.
This article will walk you through accessing the map from an activity and displaying a callout at the map center point.
Prerequisites
important
Extending Geocortex Workflow for Mobile requires development and deployment of a custom Geocortex Mobile Application using the Geocortex Mobile SDK
Follow the instructions in the Geocortex Mobile SDK page to set up the environment for extending Workflow for Geocortex Mobile.
note
A working knowledge of C# and the .NET platform is recommended before extending Workflow for Geocortex Mobile
Set up the Activity
First, the basic activity needs to be setup and registered. Below is an example of an activity setup to take text to display in the map callout.
- Activity
- Registration
MapProviderBase
Access the Accessing the map for the application uses the built-in dependency injection pattern to inject a MapProviderBase
class which exposes the Map and MapView.
To inject the MapProviderBase, add a new Autofac factory property that injects a MapProviderBase
into your custom activity.
MapView
Load the Next, we need to load the MapView
from the MapProviderFactory
.
Add a Callout at the Map Center
Finally, we can use the MapView
to get the map center and add a callout with the user's text.
tip
Operations related to UI activities have to run in Xamarin's main thread, else they will throw an error.
Test your Activity
Now you can build a workflow for Geocortex Mobile that uses your new activity!
tip
If you want your custom activity to show up with a friendly user interface in Geocortex Workflow Designer, check out Registering .NET Activities with Geocortex Workflow Designer.
The RunActivity
activity can be used to execute your activity by the name defined in PlaceCalloutAtCenter.cs
(for this example, your:unique:namespace::PlaceCalloutAtCenter
).
note
You can download this demo workflow that runs the custom activity and import it into the Geocortex Workflow Designer.
Next you need to run the workflow you just created in your Geocortex Mobile SDK project.
You can do this by configuring the layout and app config to run a workflow. You will need to copy the ID of the the workflow you created into the app.json
- App Config
- Layout
- UI