<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Apply featureEffect to a FeatureLayer | Sample | ArcGIS Maps SDK for JavaScript</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.2/"></script>
padding: var(--calcite-space-sm);
background-color: var(--calcite-color-surface-1);
color: var(--calcite-color-text-1);
font-size: var(--calcite-font-size-lg);
<body class="calcite-mode-dark">
<arcgis-map item-id="f3551252973c41fa868c08edceb504e6">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-left">
<arcgis-legend></arcgis-legend>
<div id="controls" slot="bottom-left">
<div id="description">Phoenix Average Age (2015-2020)</div>
<div>by block groups</div>
<arcgis-slider-histogram-range
range-labels-placement="center"
value-labels-display="auto"
></arcgis-slider-histogram-range>
const histogram = await $arcgis.import("@arcgis/core/smartMapping/statistics/histogram.js");
// get references to the map and slider components
const viewElement = document.querySelector("arcgis-map");
const histogramRangeSlider = document.querySelector("arcgis-slider-histogram-range");
// define the min, max, field, and starting values for the histogram and slider
const field = "MEDAGE_CY";
const startingValues = [25, 35];
// wait for the map to be ready
await viewElement.viewOnReady();
// get the Phoenix FeatureLayer from the webmap
const layer = viewElement.map.layers.getItemAt(0);
// generate the histogram for the median age field
// within the specified min and max values
const histogramResponse = await histogram({
// this function is called when the map is loaded
// and when user changes the histogram range slider thumbs
function applyFeatureEffect(layer, where) {
includedEffect: "bloom(0.9 0.6pt 0)",
excludedEffect: "blur(2.25pt) opacity(0.5)",
// set the histogram and slider properties
await histogramRangeSlider.updateFromHistogramResult(histogramResponse);
histogramRangeSlider.value = startingValues.join(",");
applyFeatureEffect(layer, await histogramRangeSlider.generateWhereClause(field));
// apply a feature effect to highlight the block groups that
// fall within the slider range
histogramRangeSlider.addEventListener("arcgisInput", async () => {
applyFeatureEffect(layer, await histogramRangeSlider.generateWhereClause(field));