▾
USA freeways styled with a unique value renderer displaying freeway types.
What is a unique types style?
A unique types style assigns distinct symbols to unique data values returned from a field or expression in a layer. You can use this style to visualize what something represents, such as:
- Show points of interest on a map (e.g. schools, parks, places of worship)
- Represent categories of data (e.g. regions, types)
- Visualize ordinal data (e.g. high, medium, and low)
How a unique types style works
This style is configured with a Unique Value Renderer. This renderer requires the following:
- A reference to a data value either from a field name, or an Arcade expression.
- A list of unique value infos or unique value groups that match a unique symbol with an expected value returned from the field or expression.
Examples
Categorical data
USA freeways are classified as interstates, state highways, U.S. highways, and other road types by a unique value renderer.
Unique types - categorical data
21 collapsed lines
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Unique types - categorical data</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { color-scheme: dark; height: 100%; margin: 0; } </style> </head>
<body> <arcgis-map item-id="55a6f89e8e25433da23a34bd6ba08630"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="bottom-left" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>2 collapsed lines
</body></html> USA freeways are classified as interstates, state highways, U.S. highways, and other road types by a unique value renderer.
- Create a unique value renderer.
- Reference the field name containing the classification values.
- Create unique value info objects and assign a symbol to each expected value.
- Optionally add a default symbol to represent features that do not have a matching value.
Unique types - categorical data
38 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Unique types - categorical data</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { color-scheme: dark; height: 100%; margin: 0; } </style> </head>
<body> <arcgis-map item-id="625fed092fb14fdbb3f79089284b383a" center="-93.268514, 44.929698" scale="577791"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="bottom-left" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
const viewElement = document.querySelector("arcgis-map"); await viewElement.viewOnReady(); viewElement.constraints.snapToZoom = false;
// Configure the base symbol style and color ramp for road types. const init = { type: "simple-line", style: "solid", width: "4px" }; const colors = ["#dc4b00", "#3c6ccc", "#d9dc00", "#91d900", "#986ba1"]; // Color and label each feature based on its matching field value. const renderer = { type: "unique-value", // autocasts as new UniqueValueRenderer() field: "RTTYP", // Treat features based on their route type code. defaultLabel: "Other", defaultSymbol: { ...init, color: colors[4] }, // The colors and labels defined here will reflect in the legend. uniqueValueInfos: [ { label: "Interstate", symbol: { ...init, color: colors[0] }, value: "I" }, { label: "US Highway", symbol: { ...init, color: colors[1] }, value: "U" }, { label: "State Highway", symbol: { ...init, color: colors[2] }, value: "S" }, { label: "Major road", symbol: { ...init, color: colors[3] }, value: "M" }, ], legendOptions: { title: "Route type" }, // Define feature draw order by class position in uniqueValueInfos. orderByClassesEnabled: true, };13 collapsed lines
const layer = new FeatureLayer({ // Fetch from a service containing primary road features. url: "https://services2.arcgis.com/FiaPA4ga0iQKduv3/ArcGIS/rest/services/Transportation_v1/FeatureServer/1", title: "US road system", renderer, minScale: 0, maxScale: 0, });
viewElement.map.add(layer); // Add the layer to the map. </script> </body></html>Points of interest (3D)
Points of interest in a Lyon city scene are represented by unique 3D symbols; picture marker symbols and web styles can create similar visualizations.
Unique types - points of interest (3D)
20 collapsed lines
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Unique types - points of interest (3D)</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-scene item-id="c6914a1571cd4e209a35019dffe4ba77"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-scene>2 collapsed lines
</body></html> Points of interest in a Lyon city scene are represented by unique 3D symbols; picture marker symbols and web styles can create similar visualizations.
- Create a unique value renderer.
- Reference the field name containing the location type.
- Create unique value info objects and assign a symbol to each expected value.
Unique types - points of interest (3D)
97 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <title>Unique types - points of interest (3D)</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-scene> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-scene>
<script type="module"> const [WebScene, FeatureLayer] = await $arcgis.import([ "@arcgis/core/WebScene.js", "@arcgis/core/layers/FeatureLayer.js", ]);
const viewElement = document.querySelector("arcgis-scene");
// Load the webscene with buildings
const webscene = new WebScene({ portalItem: { // autocasts as new PortalItem() id: "711ddecedece4fd88b728bfe4322c22b", }, });
await webscene.load(); webscene.initialViewProperties.viewingMode = "local"; webscene.initialViewProperties.viewpoint.camera = { position: { spatialReference: { wkid: 102100 }, x: 537957.5073656889, y: 5741332.269461036, z: 324.0998252798912, }, heading: 329.6097397312273, tilt: 82.28087566298973, };
viewElement.map = webscene; viewElement.environment = { lighting: { directShadowsEnabled: true, }, };
// verticalOffset shifts the symbol vertically const verticalOffset = { screenLength: 40, maxWorldLength: 500000, };
// Function that automatically creates the symbol for the points of interest function getUniqueValueSymbol(name) { // The point symbol is visualized with an icon symbol. To clearly see the location of the point // we displace the icon vertically and add a callout line. The line connects the offset symbol with the location // of the point feature. return { type: "point-3d", symbolLayers: [ { type: "icon", resource: { href: name, }, size: 20.25, }, ],
verticalOffset: verticalOffset,
callout: { type: "line", color: "white", size: 0.75, }, }; }
// Expand the code above to view how each marker // symbol is created in getUniqueValueSymbol() const pointsRenderer = { type: "unique-value", field: "Type", uniqueValueInfos: [ { value: "Restaurant", symbol: getUniqueValueSymbol("https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Restaurant.avif"), }, { value: "Church", symbol: getUniqueValueSymbol("https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Church.avif"), }, { value: "Hotel", symbol: getUniqueValueSymbol("https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Hotel.avif"), }, { value: "Park", symbol: getUniqueValueSymbol("https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Park.avif"), }, { value: "Museum", symbol: getUniqueValueSymbol("https://developers.arcgis.com/javascript/latest/assets/sample-code/visualization-point-styles/Museum.avif"), }, ], };45 collapsed lines
// Create the layer with the points of interest // Feature reduction is set to "selection" to avoid overlapping icons. // A perspective view is enabled on the layers by default. const pointsLayer = new FeatureLayer({ url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/LyonPointsOfInterest/FeatureServer", title: "Touristic attractions", renderer: pointsRenderer, outFields: ["*"], // feature reduction is set to selection because our scene contains too many points and they overlap featureReduction: { type: "selection", }, labelingInfo: [ { labelExpressionInfo: { value: "{Name}", }, symbol: { type: "label-3d", // autocasts as new LabelSymbol3D() symbolLayers: [ { type: "text", // autocasts as new TextSymbol3DLayer() material: { color: "white", }, // we set a halo on the font to make the labels more visible with any kind of background halo: { size: 1, color: [0, 0, 0, 0.5], }, size: 11, horizontalAlignment: "left", verticalAlignment: "bottom", }, ], }, }, ], });
webscene.add(pointsLayer); </script> </body></html>Ordinal data
Arcade expression classifying the numeric data
var traffic = $feature.AADT; When( traffic > 80000, "High", traffic > 20000, "Medium", "Low" ); Florida highways are categorized as low, medium, or high traffic with an Arcade expression.
Unique types - ordinal data
20 collapsed lines
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Unique types - ordinal data</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-map item-id="1e2cab3452c143698680bd075b2cbb29"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>2 collapsed lines
</body></html> Florida highways are categorized as low, medium, or high traffic with an Arcade expression.
- Create a unique value renderer.
- Write an Arcade expression that classifies traffic as low, medium, or high.
- Create unique value info objects and assign a symbol to each expected value.
- Optionally add a default symbol to represent features that do not have a matching value.
Unique types - ordinal data
42 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Unique types - ordinal data</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<script type="text/arcade" id="traffic-classification"> var traffic = $feature.AADT; When( traffic > 80000, "High", traffic > 20000, "Medium", "Low" ); </script>
<style> html, body { background-color: rgba(15, 15, 15, 1); height: 100%; margin: 0; } </style> </head>
<body> <arcgis-map center="-80.284947, 25.923399" rotation="91" scale="288895"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const [Map, FeatureLayer] = await $arcgis.import(["@arcgis/core/Map.js", "@arcgis/core/layers/FeatureLayer.js"]);
const viewElement = document.querySelector("arcgis-map");
const renderer = { type: "unique-value", valueExpression: ` var traffic = $feature.AADT; When( traffic > 80000, "High", traffic > 20000, "Medium", "Low" ); `, valueExpressionTitle: "Traffic volume", uniqueValueInfos: [ { value: "High", symbol: { type: "simple-line", color: "#810f7c", width: "6px", style: "solid", }, }, { value: "Medium", symbol: { type: "simple-line", color: "#8c96c6", width: "3px", style: "solid", }, }, { value: "Low", symbol: { type: "simple-line", color: "#9d978b", width: "1px", style: "solid", }, }, ], orderByClassesEnabled: true, };23 collapsed lines
// Set the renderer on the layer const layer = new FeatureLayer({ url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Florida_Annual_Average_Daily_Traffic/FeatureServer/0", renderer: renderer, title: "Annual average daily traffic", minScale: 0, maxSclae: 0, });
// Add the layer to the map const map = new Map({ basemap: "gray-vector", layers: [layer], });
viewElement.map = map; viewElement.constraints = { snapToZoom: false, }; </script> </body></html>Categorical data (3D)
San Francisco buildings are colored by their land-use category as residential, commercial, or mixed use.
Unique types - categorical data (3D)
20 collapsed lines
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Unique types - categorical data (3D)</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-scene item-id="3cdd4a63acc84e64a0b911ca607366a4"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-scene>2 collapsed lines
</body></html> San Francisco buildings are colored by their land-use category as residential, commercial, or mixed use.
- Create different symbols for each building type.
- Assign the symbols to a unique value renderer.
- Assign the renderer to the scene layer.
Unique types - categorical data (3D)
33 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Unique types - categorical data (3D)</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script>
<style> html, body { height: 100%; margin: 0; } </style> </head>
<body> <arcgis-scene viewing-mode="local"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle> <arcgis-expand slot="top-right" expanded> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-scene>
<script type="module"> const [Map, SceneLayer] = await $arcgis.import(["@arcgis/core/Map.js", "@arcgis/core/layers/SceneLayer.js"]);
const viewElement = document.querySelector("arcgis-scene");
const typeRenderer = { type: "unique-value", legendOptions: { title: "Building type", }, defaultSymbol: { type: "mesh-3d", symbolLayers: [ { type: "fill", material: { color: "#FFB55A", colorMixMode: "replace" }, }, ], }, defaultLabel: "Others", field: "landuse", uniqueValueInfos: [ { value: "RESIDENT", symbol: { type: "mesh-3d", symbolLayers: [ { type: "fill", material: { color: "#7EB0D5", colorMixMode: "replace" }, }, ], }, label: "Residential", }, { value: "MIXRES", symbol: { type: "mesh-3d", symbolLayers: [ { type: "fill", material: { color: "#BD7EBE", colorMixMode: "replace" }, }, ], }, label: "Residential mixed use", }, { value: "MIXED", symbol: { type: "mesh-3d", symbolLayers: [ { type: "fill", material: { color: "#B2E061", colorMixMode: "replace" }, }, ], }, label: "Non-residential mixed use", }, { value: "MIPS", symbol: { type: "mesh-3d", symbolLayers: [ { type: "fill", material: { color: "#FD7F6F", colorMixMode: "replace" }, }, ], }, label: "Office", }, ], };23 collapsed lines
// Set the renderer on the layer const buildingLayer = new SceneLayer({ url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/SF_BLDG_WSL1/SceneServer/0", renderer: typeRenderer, title: "San Francisco Buildings", });
// Add the layer to the map const map = new Map({ basemap: "gray-vector", layers: [buildingLayer], });
viewElement.map = map; viewElement.camera = { position: [-122.400638, 37.778665, 1409.396599046807], heading: 358.8186008818515, tilt: 49.046300920647525, }; </script> </body></html>Related samples and resources
Visualize features by type
Generate data-driven visualization of unique values
Coloring options for textured buildings
Extrude building footprints based on real world heights
Create a custom visualization using Arcade
API support
| 2D | 3D | Arcade | Points | Lines | Polygons | Mesh | |
|---|---|---|---|---|---|---|---|
| | | | | | | | |
| | | | | | | | |
| | | | | | | ||
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | |
- Color only
- Size variable creators only supported for points
- Size variable creators not supported in 3D