Skip to content

Learn how to use renderers to apply data-driven styling to feature layers .

Pan and zoom the map to explore the layer styles.

A feature layer is a dataset within a hosted feature service . Each feature layer consists of features that share a single geometry type (point, line, or polygon), along with a set of attributes . Client-side, feature layers can be styled using a renderer. Renderers use attribute values to apply the appropriate symbols to each feature when the layer is displayed. Additionally, renderers can work with visual variables and expressions to create more complex, data-driven visualizations.

In this tutorial, you will use three different renderers to style three hosted feature layers .

Prerequisites

Steps

Create a new pen

  1. To get started, either complete the Display a map tutorial or .

Get an access token

You need an access token with the correct privileges to access the location services used in this tutorial.

  1. Go to the Create an API key tutorial and create an API key with the following privilege(s) :
    • Privileges
      • Location services > Basemaps
    • Item access
      • Note: If you are using your own custom data layer for this tutorial, you need to grant the API key credentials access to the layer item. Learn more in Item access privileges.
  2. In CodePen, set the apiKey property on the global esriConfig variable to your access token.
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };

To learn about other ways to get an access token, go to Types of authentication.

Display a map

Follow the steps in the Display a map tutorial to add a map with the arcgis/topographic basemap layer, centered on Point Dume State Beach, Malibu, California.

Add script and modules

In a new <script> at the bottom of the <body>, use $arcgis.import() to add the FeatureLayer module.

36 collapsed lines
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
<script>
var esriConfig = {
apiKey: "YOUR_ACCESS_TOKEN",
};
</script>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.0/"></script>
<style>
html,
body {
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
<arcgis-zoom slot="top-left"></arcgis-zoom>
</arcgis-map>
<script type="module">
const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
</script>
4 collapsed lines
</body>
</html>

Style trailheads (points)

Use the SimpleRenderer, PictureMarkerSymbol, and LabelClass classes to style the points with an image, and then define label attributes to display for the Trailheads feature layer .

  1. Create a trailheadsRenderer and define it as a simple renderer. Set the symbol property to draw a hiker image accessed from its url.

    39 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    5 collapsed lines
    </script>
    </body>
    </html>
  2. Create a trailheadsLabels and set the symbol property to draw a label with the TRL_NAME.

    50 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    6 collapsed lines
    </script>
    </body>
    </html>
  3. Create a trailheads FeatureLayer. Set the url property to access its URL endpoint. Set the renderer and labelingInfo before adding trailheads to the map. The feature layer will autocast the renderer and labelingInfo to create class instances of the objects.

    65 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    5 collapsed lines
    </script>
    </body>
    </html>
  4. Use document.querySelector() to get a reference to the Map component, then wait for it to be ready with the viewOnReady method. Then, add trailheads layer to the map after the renderer and label definitions.

    36 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    </script>
    4 collapsed lines
    </body>
    </html>
  5. View hiker symbols with trailhead names.

Style trails (lines)

Use the SimpleRenderer and VisualVariable classes to style trails in the Trails feature layer . Visual variables define the attribute to use to style trails with a greater elevation gain wider compared to trails with smaller elevation changes. This is one form of data-driven visualization.

  1. Create a trailsRenderer and define it as a simple renderer.

    83 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    5 collapsed lines
    </script>
    </body>
    </html>
  2. In the visualVariables array, set the field to ELEV_GAIN to determine line width.

    92 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    5 collapsed lines
    </script>
    </body>
    </html>
  3. Create a trails FeatureLayer. Set the url to access its URL endpoint.

    104 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    5 collapsed lines
    </script>
    </body>
    </html>
  4. Add trails layer to the map. Set the renderer and opacity properties before adding trails to the map. The feature layer will autocast the renderer a create class instances of the object.

    111 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    5 collapsed lines
    </script>
    </body>
    </html>
  5. View trails of differing widths based on elevation gain.

Show bike-only trails (lines)

You can use a renderer and definition expression to style a subset of data from a feature layer . To style bike-only trails from the Trails feature layer, use the definitionExpression, SimpleRenderer and SimpleLineSymbol classes. The layer is added on top of the existing trails layer.

  1. Create a bikeTrailsRenderer and define it as a simple renderer. Set the symbol to draw a line that is styled with dots in pink.

    113 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    // Add bikes only trails
    const bikeTrailsRenderer = {
    type: "simple",
    symbol: {
    type: "simple-line",
    style: "short-dot",
    color: "#FF91FF",
    width: "1px",
    },
    };
    5 collapsed lines
    </script>
    </body>
    </html>
  2. Create a bikeTrails FeatureLayer and set the url and renderer properties. Set the definitionExpression (a SQL where clause) to access bike trails from the Trails feature layer before adding bikeTrails to the map.

    124 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    // Add bikes only trails
    const bikeTrailsRenderer = {
    type: "simple",
    symbol: {
    type: "simple-line",
    style: "short-dot",
    color: "#FF91FF",
    width: "1px",
    },
    };
    const bikeTrails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: bikeTrailsRenderer,
    definitionExpression: "USE_BIKE = 'YES'",
    });
    5 collapsed lines
    </script>
    </body>
    </html>
  3. Add bikeTrails layer to the map. The feature layer will autocast the renderer a create class instances of the object.

    130 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    // Add bikes only trails
    const bikeTrailsRenderer = {
    type: "simple",
    symbol: {
    type: "simple-line",
    style: "short-dot",
    color: "#FF91FF",
    width: "1px",
    },
    };
    const bikeTrails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: bikeTrailsRenderer,
    definitionExpression: "USE_BIKE = 'YES'",
    });
    viewElement.map.add(bikeTrails, 1);
    5 collapsed lines
    </script>
    </body>
    </html>
  4. View the location of bike trails in relation to other trails.

Style open spaces (polygons)

You can use renderers to style feature layer data by unique attribute values. Use the UniqueValueRenderer and SimpleFillSymbol classes to style polygon features with different fill colors, based on the TYPE attribute in the Parks and Open Spaces feature layer .

  1. Create a createFillSymbol function with value and color as parameters. The function will return a solid, simple-fill symbol for each park type.

    132 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    // Add bikes only trails
    const bikeTrailsRenderer = {
    type: "simple",
    symbol: {
    type: "simple-line",
    style: "short-dot",
    color: "#FF91FF",
    width: "1px",
    },
    };
    const bikeTrails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: bikeTrailsRenderer,
    definitionExpression: "USE_BIKE = 'YES'",
    });
    viewElement.map.add(bikeTrails, 1);
    // Add parks with a class breaks renderer and unique symbols
    function createFillSymbol(value, color) {
    return {
    value: value,
    symbol: {
    color: color,
    type: "simple-fill",
    style: "solid",
    outline: {
    style: "none",
    },
    },
    label: value,
    };
    }
    5 collapsed lines
    </script>
    </body>
    </html>
  2. Create an openSpacesRenderer and define it as unique-value. Set the field property to TYPE. In the uniqueValueInfos array, set unique colors for each park type.

    148 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    // Add bikes only trails
    const bikeTrailsRenderer = {
    type: "simple",
    symbol: {
    type: "simple-line",
    style: "short-dot",
    color: "#FF91FF",
    width: "1px",
    },
    };
    const bikeTrails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: bikeTrailsRenderer,
    definitionExpression: "USE_BIKE = 'YES'",
    });
    viewElement.map.add(bikeTrails, 1);
    // Add parks with a class breaks renderer and unique symbols
    function createFillSymbol(value, color) {
    return {
    value: value,
    symbol: {
    color: color,
    type: "simple-fill",
    style: "solid",
    outline: {
    style: "none",
    },
    },
    label: value,
    };
    }
    const openSpacesRenderer = {
    type: "unique-value",
    field: "TYPE",
    uniqueValueInfos: [
    createFillSymbol("Natural Areas", "#9E559C"),
    createFillSymbol("Regional Open Space", "#A7C636"),
    createFillSymbol("Local Park", "#149ECE"),
    createFillSymbol("Regional Recreation Park", "#ED5151"),
    ],
    };
    5 collapsed lines
    </script>
    </body>
    </html>
  3. Create an openspaces FeatureLayer. Set the url to access its URL endpoint. Set the renderer and opacity properties before adding openspacesto the map. The feature layer will autocast the renderer to create class instances of the object.

    159 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    // Add bikes only trails
    const bikeTrailsRenderer = {
    type: "simple",
    symbol: {
    type: "simple-line",
    style: "short-dot",
    color: "#FF91FF",
    width: "1px",
    },
    };
    const bikeTrails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: bikeTrailsRenderer,
    definitionExpression: "USE_BIKE = 'YES'",
    });
    viewElement.map.add(bikeTrails, 1);
    // Add parks with a class breaks renderer and unique symbols
    function createFillSymbol(value, color) {
    return {
    value: value,
    symbol: {
    color: color,
    type: "simple-fill",
    style: "solid",
    outline: {
    style: "none",
    },
    },
    label: value,
    };
    }
    const openSpacesRenderer = {
    type: "unique-value",
    field: "TYPE",
    uniqueValueInfos: [
    createFillSymbol("Natural Areas", "#9E559C"),
    createFillSymbol("Regional Open Space", "#A7C636"),
    createFillSymbol("Local Park", "#149ECE"),
    createFillSymbol("Regional Recreation Park", "#ED5151"),
    ],
    };
    // Create the layer and set the renderer
    const openspaces = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space/FeatureServer/0",
    renderer: openSpacesRenderer,
    opacity: 0.2,
    });
    5 collapsed lines
    </script>
    </body>
    </html>
  4. Add openspaces layer to the map. The feature layer will autocast the renderer to create class instances of the object.

    166 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Style a feature layer</title>
    <script>
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    </head>
    <body>
    <arcgis-map basemap="arcgis/topographic" center="-118.805, 34.020" zoom="13">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    // Define a simple renderer and symbol
    const trailheadsRenderer = {
    type: "simple",
    symbol: {
    type: "picture-marker",
    url: "http://static.arcgis.com/images/Symbols/NPS/npsPictograph_0231b.png",
    width: "18px",
    height: "18px",
    },
    };
    // Define a label for the trailheads
    const trailheadsLabels = {
    symbol: {
    type: "text",
    color: "#FFFFFF",
    haloColor: "#5E8D74",
    haloSize: "2px",
    font: {
    size: "12px",
    family: "Noto Sans",
    style: "italic",
    weight: "normal",
    },
    },
    labelPlacement: "above-center",
    labelExpressionInfo: {
    expression: "$feature.TRL_NAME",
    },
    };
    // Create the layer and set the renderer
    const trailheads = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0",
    renderer: trailheadsRenderer,
    labelingInfo: [trailheadsLabels],
    });
    viewElement.map.add(trailheads);
    // Define a unique value renderer and symbols
    const trailsRenderer = {
    type: "simple",
    symbol: {
    color: "#BA55D3",
    type: "simple-line",
    style: "solid",
    },
    visualVariables: [
    {
    type: "size",
    field: "ELEV_GAIN",
    minDataValue: 0,
    maxDataValue: 2300,
    minSize: "3px",
    maxSize: "7px",
    },
    ],
    };
    // Create the layer and set the renderer
    const trails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: trailsRenderer,
    opacity: 0.75,
    });
    viewElement.map.add(trails, 0);
    // Add bikes only trails
    const bikeTrailsRenderer = {
    type: "simple",
    symbol: {
    type: "simple-line",
    style: "short-dot",
    color: "#FF91FF",
    width: "1px",
    },
    };
    const bikeTrails = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
    renderer: bikeTrailsRenderer,
    definitionExpression: "USE_BIKE = 'YES'",
    });
    viewElement.map.add(bikeTrails, 1);
    // Add parks with a class breaks renderer and unique symbols
    function createFillSymbol(value, color) {
    return {
    value: value,
    symbol: {
    color: color,
    type: "simple-fill",
    style: "solid",
    outline: {
    style: "none",
    },
    },
    label: value,
    };
    }
    const openSpacesRenderer = {
    type: "unique-value",
    field: "TYPE",
    uniqueValueInfos: [
    createFillSymbol("Natural Areas", "#9E559C"),
    createFillSymbol("Regional Open Space", "#A7C636"),
    createFillSymbol("Local Park", "#149ECE"),
    createFillSymbol("Regional Recreation Park", "#ED5151"),
    ],
    };
    // Create the layer and set the renderer
    const openspaces = new FeatureLayer({
    url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space/FeatureServer/0",
    renderer: openSpacesRenderer,
    opacity: 0.2,
    });
    viewElement.map.add(openspaces, 0);
    6 collapsed lines
    </script>
    </body>
    </html>

Run the app

In CodePen, run your code to display the map.

The completed map should display all of the layers with a unique, data-driven style.

What’s next?

Learn how to use additional SDK features and ArcGIS services in these tutorials: