View on GitHub Sample viewer app

Combine multiple symbols from a mobile style file into a single symbol.

Image of read symbols from mobile style file

Use case

You may choose to display individual elements of a dataset like a water infrastructure network (such as valves, nodes, or endpoints) with the same basic shape, but wish to modify characteristics of elements according to some technical specifications. Multilayer symbols lets you add or remove components or modify the colors to create advanced symbol styles.

How to use the sample

Select a symbol and a color from each of the category lists to create an emoji. A preview of the symbol is updated as selections are made. The size of the symbol can be set using the slider. Click the map to create a point graphic using the customized emoji symbol, and click “Reset” to clear all graphics from the display.

How it works

  1. Create a new SymbolStyle from a stylx file, and load it.
  2. Get a set of default search parameters using symbolStyle.getDefaultSearchParametersAsync(), and use these to retrieve a list of all symbols within the style file: symbolStyle.searchSymbolsAsync(defaultSearchParameters).
  3. Get the SymbolStyleSearchResult, which contains the symbols, as well as their names, keys, and categories.
  4. Use a List of keys of the desired symbols to build a composite symbol using symbolStyle.getSymbolAsync(symbolKeys).
  5. Create a Graphic using the MultilayerPointSymbol.

Relevant API

  • MultilayerPointSymbol
  • MultilayerSymbol
  • SymbolLayer
  • SymbolStyle
  • SymbolStyleSearchParameters

About the data

The mobile style file used in this sample was created using ArcGIS Pro, and is hosted on ArcGIS Online. It contains symbol layers that can be combined to create emojis.

Additional information

While each of these symbols can be created from scratch, a more convenient workflow is to author them using ArcGIS Pro and store them in a mobile style file (.stylx). ArcGIS Maps SDKs for Native Apps can read symbols from a mobile style, and you can modify and combine them as needed in your app.

Tags

advanced symbology, mobile style, multilayer, stylx

Sample Code

module-info.java module-info.java ReadSymbolsFromMobileStyleFileController.java ReadSymbolsFromMobileStyleFileSample.java SymbolLayerInfoListCell.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.read_symbols_from_mobile_style_file {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
// make all @FXML annotated objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.read_symbols_from_mobile_style_file to javafx.fxml;
exports com.esri.samples.read_symbols_from_mobile_style_file;
}