Use the Add Graphics Activity for Visualization

The Add Graphics activity allows you to add features to a graphics layer. If the features have symbols, they are displayed on the map.

If you want, you can specify the graphics layer to use. If you specify a layer that already exists, by default the activity aggregates the new features with any existing features in the layer. You can use this fact to accumulate features in a graphics layer. If you do not want to carry forward existing features, set the Remove All Features input to true. This clears the layer before adding the new features.

If you specify a layer that does not exist, the activity creates the layer. If you do not specify the layer, the activity uses the map's default graphics layer.

Example 1 - Display a Dynamically Created Feature

This example shows you how to use an Add Graphics activity to display a feature that is created at run-time. The workflow uses a Get Symbol From JSON activity to define the feature's symbol and a Geometry Picker form element to get the geometry from the user. The feature is created using a Create Feature activity. The layer specified in the Add Graphics activity does not exist, so the activity creates a new layer to add the features to.

Workflow Logic

The workflow has the following activities, in the order shown:

To use the Add Graphics activity to show a dynamically created feature on the map:

  1. Open Workflow Designer.

  2. In a new, blank workflow, add the following activities and connect them in the given order:

  3. Get Symbol From JSON (symbol1): Set the Json input to:

    {
       "type": "esriSFS",
       "style": "esriSFSSolid",
       "color": [0,255,0,100],
       "outline": 
       {
          "style" : "esriSLSSolid",
          "color": [0,255,255,200],
          "width": 2
       }
    }

    This symbol has an aqua outline and green fill.

  4. Display Form (form1):

    1. Double-click the Display Form activity to edit it.

    2. Add a Geometry Picker form element. Use the Geometry Picker's default configuration.

    3. Click Start in the breadcrumbs to return to the main workflow.

  5. Create Feature: Configure the inputs as follows:

  6. Add Graphics: Configure the inputs as follows:

  7. Run the workflow in the Sandbox using the 2D Map (ArcGIS API v3.x) environment.

    To run a workflow in the Sandbox, click Info in the sidebar, click Run in Sandbox, select the environment, configure the Sandbox settings, and then click Run Workflow. You can press F12 at any time to see the verbose log.

    The workflow displays the geometry entered by the user using a fill symbol.

  8. Press Ctrl+S to save the workflow.

Example 2 - Display Query Results

This example shows you how to use an Add Graphics activity to display the features returned by a Query Layer activity. The query returns four US states. The workflow zooms the map to the returned states, assigns a fill symbol to each feature, and then uses the Add Graphics activity to show the features on the map. This example specifies a graphics layer that does not exist, so the activity creates a new layer to add the features to.

Workflow Logic

The workflow has the following activities, in the order shown:

To use the Add Graphics activity to show query results on the map:

  1. Open Workflow Designer.

  2. In a new, blank workflow, add the following activities and connect them in the given order:

  3. Query Layer (query1): Configure the inputs:

  4. Set Map Extent: Set the Features input to: =$query1.features

  5. Get Symbol From JSON (symbol1): Set the Json input to:

    {
       "type": "esriSFS",
       "style": "esriSFSSolid",
       "color": [255,255,0,255],
       "outline": 
       {
          "style" : "esriSLSSolid",
          "color": [255,165,0,255],
          "width": 2
       }
    }

    This symbol has an orange outline and yellow fill.

  6. For Each:

    1. Set the Items input to: =$query1.features

    2. Double-click the For Each activity to open its subworkflow.

    3. Add a Set Feature Symbol activity, connect it to the For Each block, and configure the inputs as follows:

      • Feature: =$forEach1.item

      • Symbol: =$symbol1.symbol

    4. Click Start in the breadcrumbs to return to the main workflow.

  7. Add Graphics: Configure the inputs as follows:

  8. Run the workflow in the Sandbox. Do not use the No Map environment.

    To run a workflow in the Sandbox, click Info in the sidebar, click Run in Sandbox, select the environment, configure the Sandbox settings, and then click Run Workflow. You can press F12 at any time to see the verbose log.

    The map zooms to the states returned by the query and displays the symbols.

  9. Press Ctrl+S to save the workflow.

© 2019 Latitude Geographics Group Ltd. All Rights Reserved.

Documentation Version 5.15