Configure feature symbol after queryingFeatures

380
4
Jump to solution
05-17-2023 02:06 PM
BhavinSanghani
Occasional Contributor II

Is there a way to configure feature symbol when highlighting them? I have written sample code here. See https://codepen.io/b2810s/pen/VwEEpbx .

However, it goes through the loop to configure the symbol with each feature. How can I avoid this loop? Consider the scenario where I need to highlight multiple features from multiple layers. 

It was easier with ArcGIS Javascript API 3.x to configure the selection symbology with the feature layer. But I don't find similar with the 4.x.

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Instead of adding GraphicsLayer, you can create a client-side FeatureLayer and set the renderer of the feature layer. This way you don't have assign a symbol to every single graphic. Take a look at this sample: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-featurelayer-coll...

View solution in original post

4 Replies
UndralBatsukh
Esri Regular Contributor

4.x does not have concept of selection symbol. You can change the highlightOptions for the layer view. Please take a look this sample as this shows how to change the layer view's highlightOptions: https://developers.arcgis.com/javascript/latest/sample-code/highlightoptions-layerviews/

0 Kudos
BhavinSanghani
Occasional Contributor II

The reason I am adding Graphic object manually so I can display the symbology as per customer's preference. highlightOptions doesn't allow to display different symbols with different styles. Is there any plan to support it in future? Or any other alternatives for this scenario?

0 Kudos
UndralBatsukh
Esri Regular Contributor

Instead of adding GraphicsLayer, you can create a client-side FeatureLayer and set the renderer of the feature layer. This way you don't have assign a symbol to every single graphic. Take a look at this sample: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-featurelayer-coll...

BhavinSanghani
Occasional Contributor II

@UndralBatsukh This is a good suggestion and it will work for me, thanks!

0 Kudos