Feature Layer Symbology Change

397
5
02-07-2023 01:16 PM
MichaelWen_Timmons
New Contributor III

I have an application that uses a disconnected feature layer that has temporal features.

I am trying to use the TimeSlider to create a breadcrumb visual effect where the features that match the current value of the timeslider will have one symbology while those with temporal value that are less than the timeslider will have a smaller, less pronounced symbology. 

The approach that I have tried is to watch the timeExtent of the timeslider and use applyEdits on the featurelayer to modify an attribute that is used by the uniqueValueRenderer to vary the symbology. 

It works to some extent but with a jumpy effect that's probably caused by the lag associated with applyEdits.

Is there a way that symbology can be changed without using applyEdits? Something like visualVariables but can be used to change symbols. 

0 Kudos
5 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

You should not have to use applyEdits at all. You can apply featureEffect to the FeatureLayerView. So that the included features will be more prominent while excluded features are subdued. 

We have couple of samples that should help you. 

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=timeslider-filter

https://developers.arcgis.com/javascript/latest/sample-code/featureeffect-layers-histogram/

 

0 Kudos
MichaelWen_Timmons
New Contributor III

Is there an effect that I can use to make older features disappear? 

0 Kudos
UndralBatsukh
Esri Regular Contributor

You can use FeatureLayerView.filter if you do not want to show your older features. FeatureEffects are useful if you want to display display features that are included in the criteria differently than those that are not included in the criteria. If you for some reason must use featureEffect then use can use opacity effect and make the features completely transparent. The document explains how to use the effects.

This sample shows how use FeatureLayerView.filter to show only features that meet the criteria: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=featurefilter-attributes

0 Kudos
MichaelWen_Timmons
New Contributor III

I rewrote the application to use layerview filter to hide older features and commented out all applyEdits. The jerky effect is still there as you can see on the video. You can also see the older feature briefly before they disappear. Is there a way to instruct the layer to hide the older feature first before rendering the new one?

        that.view.whenLayerView(globals.vehicleFeatureLayer).then(function(layerView) {
          layerView.filter = {
            where: "utc_time > " + (globals.historyTime.getTime() - 30000)
          }
        })
 
 
0 Kudos
MichaelWen_Timmons
New Contributor III

I am using different symbols for current and historic features. It doesn't look like there is any effect that can be used to swap out symbols. If I can use a featureEffect to make any non-current feature disappear before the applyEdits can catch up then that should resolve the temporary duplicate that I'm seeing sometimes. 

I tried out the code but it does not look like featureEffect is having any effect on the symbol. As a sanity check I used the follow code to make all features transparent but there seemed to be no change in the appearance of the symbols.

    const includedEffect = "opacity(10%)";
    that.view.whenLayerView(globals.vehicleFeatureLayer).then(function(layerView) {
      layerView.FeatureEffect = new FeatureEffect({
        filter: new FeatureFilter({
          where: "1=1"  
        }),
        includedEffect: includedEffect,
        excludedEffect: "grayscale(25%) blur(5px) opacity(25%)"
      });
    })
 
As you can see the features below are fully opaque.
I verified in Dev Console that the posted code was run.
I can't see where I might be using featureEffect wrong.
I'm using ArcGIS Core 4.24.7
Any help is appreciated.
MichaelWen_Timmons_0-1675979379908.png

 

 

0 Kudos