import type { GroupByFunction, GroupByFunctionGrouping, GroupByType, Filter, FilterFilterName } from "@arcgis/core/widgets/FeatureTemplates/types.js";Type definitions
GroupByFunction
- Type parameters
- <T = any>
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The function used when setting the FeatureTemplates.groupBy property. It is
used to customize the grouping of template items. This can aid
in managing various template items and how they display within the widget. This takes an object containing a
template and a layer property.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| grouping | An object containing the properties referenced below. | |
- Returns
- object
Groups consist of a group
keyandlabel. These are shown in the UI. If both thekeyandlabelare identical, return astring. Otherwise, return anobjectwithkey/nameproperties. This gives finer control of the groups.
- Examples
- // This example shows using a function to check if// the layer title contains the word 'military'. If so,// return a group of items called "All Military Templates"function customGroup(grouping) {// Consolidate all military layersif (grouping.layer.title.toLowerCase().indexOf("military") > -1) {return "All Military Templates"}// Otherwise, group by layer titlereturn grouping.layer.title;}// Create the FeatureTemplates widgettemplates = new FeatureTemplates({container: "templatesDiv",layers: layers,groupBy: customGroup});// Group template items by layers.// This function is as same as setting// the groupBy property to "layer" option.function groupByLayer (grouping) {const group = {key: grouping.layer,name: grouping.layer.title};return group;}// Create the FeatureTemplates widgetconst templates = new FeatureTemplates({container: "templatesDiv",layers: layers,groupBy: groupByLayer});
GroupByFunctionGrouping
- Since
- ArcGIS Maps SDK for JavaScript 5.0
template
- Since
- ArcGIS Maps SDK for JavaScript 5.0
FeatureTemplate associated with the layer.
layer
- Since
- ArcGIS Maps SDK for JavaScript 5.0
FeatureLayer instance referenced in FeatureTemplates.layers property.
GroupByType
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Type
- "none" | "layer" | "geometry" | GroupByFunction
Filter
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The filter used when setting the FeatureTemplates.filterFunction property. It takes an object containing a name property of the template item and returns whether or not to include it.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| filterName | An object containing a | |
- Example
- // Filter and display templates only if their labels contain the word `Street`function myFilterFunction(filter) {let containsName = filter.label.includes("Street");return containsName;}// Create the FeatureTemplates widgettemplates = new FeatureTemplates({container: "templatesDiv",visibleElements: {filter: false, // disable the default filter UI}layers: [featureLayer], // in this example, one layer is usedfilterFunction: myFilterFunction});
FilterFilterName
- Since
- ArcGIS Maps SDK for JavaScript 5.0
label
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The name of the template item to filter.