The url and collectionId properties are required when creating a new OGCFeatureLayer.
Use dark colors for code blocksCopy
1
2
3
4
5
6
const wineryLayer = new OGCFeatureLayer({
url: "https://demo.ldproxy.net/vineyards", // url to the OGC servicecollectionId: "vineyards", // unique id of the collectionlabelingInfo: [{ ... }],
renderer: { ... }
});
Filter the features on the OGCFeatureLayerView
The OGCFeatureLayer supports working with your features on the client through the OGCFeatureLayerView.
We can use the filter button in the top-left of the view to filter the layerView by the area of the winery. When a filter is selected, we call the following function to apply the filter and effect.
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
functionfilterByType(event) {
// determine filter definition based on the selected typeconst selectedType = event.target.getAttribute("data");
if (!selectedType) {
return; // do not set filter if one of the filters has not been clicked }
let filterDef = "";
switch (selectedType) {
case"lessThan50":
filterDef = "area_ha < 50";
break;
case"fiftyTo100":
filterDef = "area_ha >= 50 AND area_ha <= 100";
break;
case"greater100":
filterDef = "area_ha >= 100";
break;
default:
}
// apply the effect to the features wineryLayerView.featureEffect = {
filter: {
where: filterDef
},
excludedEffect: "opacity(20%)" };
}