Select to view content in your preferred language

StreamLayer: FeatureEffect, FeatureFilter and Definition Expresion Issues

1125
3
Jump to solution
01-03-2022 03:42 AM
LuisAntonioRodriguezGonzalez
Emerging Contributor

ArcGIS API for JavaScript 4.22

I have a web app that shows a WebMap with a Stream Layer. This app allows you apply Feature Effect,  FeatureFilter or a Definition Expresion on an Stream Layer. Optionally you can set labels on the Stream Layer.

 

 

 

"esri/layers/support/FeatureEffect",
"esri/layers/support/FeatureFilter"

 

 

 

I have found these issues:

  • FeatureEffect does not work correctly with labelingInfo. After applying a filtered featureEffect, only the labels from the last featureEffect with filter are visible. By setting streamLayerView.featureEffect = null, only the labels from the last filtered featureEffect are displayed. In addition, when you change the FeatureEffect filter, the first filter applied is kept.

 

 

 

// Apply FeatureEffect
let featureFilter = new FeatureFilter({
	where: "OriginID = '" + document.getElementById("streamFilterText").value + "'"
  });
if (tipoFiltro === "effect") {
	streamLayerView.featureEffect = new FeatureEffect({
	  filter: featureFilter,
	  excludedEffect: "grayscale(100%) opacity(30%)"
	});
}

 

 

 

  • FeatureFilter does not work correctly with labelingInfo. Firts I apply a FeatureFilter, then I set streamLayerView.featureEffect = null  and this code does not work, because the first filter applied is kept. If I apply other attribute filfer, the filter code does not work, because the first filter applied is kept. If I apply other attribute filfer.

 

 

 

let featureFilter = new FeatureFilter({
	where: "OriginID = '" + document.getElementById("streamFilterText").value + "'"
  });

  . . .
else if (tipoFiltro === "filter")
	streamLayerView.filter = featureFilter;

 

 

 

  • definitionExpression does not work. When I set a definitionExpression on the StreamLayer, the points disappear from the map and then new points are showed on the map, but the features are not filtered based on "OriginID = '" + document.getElementById("streamFilterText").value + "'".

 

I attach the source code.

These are the guidelines to use de web app:

  • First, choose one of these options:
    Feature Effect
    Filter
    Definition Expresion
  • Optionally, you can check Create labels to apply labels on the Stream Layer
  • Second, click on "Add stream layer" button
  • Third, write an OriginID in the input, por explample: KLAS, KLAX, N/A, ... and click on "Apply attribute filter" button. By clicking on "Clear filter" you remove the Feature Effect,  FeatureFilter or a Definition Expresion
  • If you want change Feature Effect, Filter, Definition Expresion and Create labels options, you have to click on "Remove stream layer" button, select the options and click on "Add stream layer" button
0 Kudos
1 Solution

Accepted Solutions
3 Replies
ReneRubalcava
Honored Contributor
0 Kudos
OliviaZ_Meowth
Occasional Contributor

One thing notice from the sample code, in line 233 streamLayerView.definitionExpression = null;

streamLayerView does not have definitionExpression property. StreamLayerView | API Reference | ArcGIS API for JavaScript 4.22 | ArcGIS Developer

0 Kudos
LuisAntonioRodriguezGonzalez
Emerging Contributor

Thank you. StreamLayer has definitionExpression property: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#definitio...

I've replaced

streamLayerView.definitionExpression = null;

by

streamLayer.definitionExpression = null;

But definitionExpression does not work with an StreamLayer.

0 Kudos