< meta name = "viewport" content = "width=device-width, initial-scale=1, shrink-to-fit=no" />
< title >Binning - Filter by category | 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.0/" ></ script >
--calcite-panel-space : 10 px ;
--calcite-panel-background-color : #2b2b2b ;
< body class = "calcite-mode-dark" >
< arcgis-map center = "-89.305647, 28.85186" scale = "3321566" >
< arcgis-zoom slot = "top-left" ></ arcgis-zoom >
< calcite-panel id = "filter-panel" heading = "Filter by well type" slot = "top-right" >
selection-appearance = "border"
< calcite-option label = "all" value = "all" ></ calcite-option >
< calcite-option label = "Development" value = "Development" ></ calcite-option >
< calcite-option label = "Exploratory" value = "Exploratory" ></ calcite-option >
< calcite-option label = "Core Test" value = "Core Test" ></ calcite-option >
< calcite-option label = "Relief" value = "Relief" ></ calcite-option >
< arcgis-legend ></ arcgis-legend >
const [ Map , FeatureLayer , AggregateField ] = await $arcgis . import ([
"@arcgis/core/layers/FeatureLayer.js" ,
"@arcgis/core/layers/support/AggregateField.js" ,
const colors = [ "#48385f" , "#995375" , "#db4a5b" , "#fc9a59" , "#fee086" ];
const viewElement = document . querySelector ( "arcgis-map" );
// Define feature reduction to show binned oil and natural gas wells
const featureReduction = {
deconflictionStrategy : "none" ,
type : "text" , // autocasts as new TextSymbol()
expression : "Text($feature.aggregateCount, '#,###')" ,
title : "Oil and gas wells" ,
content : "This area has {aggregateCount} oil and gas wells." ,
{ value : 0 , color : colors [ 0 ] },
{ value : 25 , color : colors [ 1 ] },
{ value : 50 , color : colors [ 2 ] },
{ value : 100 , color : colors [ 3 ] },
{ value : 200 , color : colors [ 4 ] },
// Oil and natural gas wells in Outer Continental Shelf (OCS) waters
const layer = new FeatureLayer ({
id : "caa1bf11657547cc9a1b9d90f41ac405" ,
outFields : [ "TYPE_CODE_DESC" ],
id : "9cc4e190b8764e8880bd77cb16b9a30a" ,
viewElement . constraints = {
const layerView = await viewElement . whenLayerView ( layer );
// Apply filter to the layer view based on the selected well type
const typeSelect = document . getElementById ( "type-select" );
typeSelect . addEventListener ( "calciteSelectChange" , () => {
const value = typeSelect . value ;
where : `TYPE_CODE_DESC = ' ${ value } '` ,