Using Custom Pro Symbols in ArcGIS Runtime

1179
5
11-01-2017 12:23 PM
Labels (1)
LucasDanzinger
Esri Frequent Contributor
2 5 1,179

ArcGIS Pro is a powerful desktop application that allows you to perform many essential GIS tasks, such as designing maps and symbols. One common requirement that many organizations have is to use a standardized set of symbols in their maps, so that they have a consistent look and feel associated with their maps and their brand. The best way to handle this is to create a Style and to store all of your symbols in the Style. You can then share this Style file with anyone in your organization so they can access the same symbols. This is not a new workflow - Styles have been around in ArcMap for quite some time. But one really cool new things you can do with ArcGIS Pro is create Mobile Style Files, which are style files that can be shared with ArcGIS Runtime based applications. This means that you can create your custom symbol sets in ArcGIS Pro, and then apply those same symbols to graphics and features in ArcGIS Runtime Apps. If you have ever wanted to create and display intricate custom symbols that are beyond what the Runtime API will allow you to programmatically create, then this workflow is for you.

Step 1: Create a Mobile Style File in Pro

  • Open Pro and create a new Project
  • Open your Catalog Window and find the "Styles" section
  • Right click Styles and select New > New Mobile Style.
  • Give a name and location to create the style file.
  • More details on the specs and limitations of a Mobile Style file can be found here.

Step 2: Create and save a custom symbol into the Style File

  • Insert a new map and add some vector data to your map
  • Select the layer in the Contents pane, right click, and select Symbology
  • This will open the Symbology pane and display the current symbol for the layer. You can modify this by changing color, size, and adding additional symbol layers. This allows you to make a completely customized symbol. Modify the symbol to your liking, and press Apply to see the symbol applied to the map.
  • Once you have the desired output, click the "hamburger" icon in the top right of the Symbology pane and select Save Symbol to Style.
  • Fill in the Name and Category and optionally give it a Key. This key will be used for fetching the Symbol in Runtime. (You could also query for all symbols and sort through the results programmatically, but retaining and fetching from a Key is the most straight forward way to get started)
  • From the Style dropdown, select your newly created Style file.
  • Click OK, and your symbol is now saved to your Style file and is ready for use in ArcGIS Runtime.
  • More details about the process of creating symbol styles can be found here.

Step 3: Consume in Runtime

  • Create a GraphicsOverlay object to display Graphics in a MapView
  • m_graphicsOverlay = new GraphicsOverlay(this);‍‍
  • Create a SimpleRenderer and set this to the GraphicsOverlay. A SimpleRenderer will display the same symbol for every graphic in the overlay
m_simpleRenderer = new SimpleRenderer(this);
m_graphicsOverlay->setRenderer(m_simpleRenderer);‍‍‍‍
  • Create a SymbolStyle object by passing in the path to the constructor 
m_symbolStyle = new SymbolStyle("/Users/<username>/Desktop/RuntimeStyles.stylx", this);‍‍‍
  • Connect to the SymbolStyle::fetchSignalCompleted signal. This will emit when a symbol has been asynchronously fetched from the Style. A Symbol object is passed through as a parameter, and this symbol object can then be used to set the symbol used by the SimpleRenderer
connect(m_symbolStyle, &SymbolStyle::fetchSymbolCompleted, this, [this](QUuid, Symbol* symbol)
{
  m_simpleRenderer->setSymbol(symbol);
});‍‍‍‍‍‍‍‍‍‍‍‍
  • Fetch the symbol by the unique Key defined in Pro 
  • m_symbolStyle->fetchSymbol(QStringList{"RuntimeArrow"});‍‍
  • Add graphics to your graphics overlay, and they will be symbolized with the custom symbol. In the below example, a simple black line with an arrow at the end of the line was created in Pro and consumed in ArcGIS Runtime.

An example ArcGIS Runtime project can be found here. You will need to update the path to your style file and any keywords that you may be searching for.

5 Comments
NorbertThoden
Occasional Contributor III

Hi Luke!

  1. Can you make clear if this works for the 3d scene also?
  2. Is it possible to scale the arrow?
    (Scale the lineWithArrow and keep the ratio between line thickness and arrowSize)

Thanks!

LucasDanzinger
Esri Frequent Contributor

Hi Norbert, 

I modified the project to switch out MapView to SceneView, and here are my results:

You can't yet scale the arrow/line on the client side, although you could change it in Pro, and have you style file contain several different sizes. We are hoping to start supporting client side modification (and creation) of these types of complex symbols soon in ArcGIS Runtime.

TroyFoster
New Contributor III

Have you noticed anything with the symbols brought from Pro to Runtime being larger in Runtime?  ex: I make a point marker symbol with a box with an outline width of 30 pt.  I then take it over to runtime and the symbol is noticeably larger.  I took screenshots and measured the pixels in gimp and the symbol in pro was 40 pixels wide while in runtime it was 55 pixels wide. 

Lucas Danzinger

LucasDanzinger
Esri Frequent Contributor

Troy- the symbol sizes can vary slightly. What platforms are you testing on for Pro and Runtime? One big difference is that Pro measures symbols in points and runtime uses device independent pixels. Runtime also takes into account the screen scaling factor applied on a PC whereas I am not sure if Pro does the same or not. Long story short, you may see some differences in size depending on several factors. This difference is likely apparent from things like feature services published from Pro and consumed in Runtime as well.

TroyFoster
New Contributor III

Pro is on windows, runtime is on ubuntu 16.04 linux.

This could also be part of why 2525 icons in runtime look huge.

About the Author
I'm a Geographer working in Product Development at Esri, focusing my time on the ArcGIS Runtime SDKs. I'm an Esri Certified ArcGIS Desktop Professional (10 years experience working with ArcGIS) with a wide range of technical skills including native application development, spatial databases, desktop/web GIS, and scripting. My Master's degree is in GIS with a focus in Natural Resource Management. Currently, I'm most interested in building cross-platform and lightweight apps using our ArcGIS Runtime SDK for Qt.