Allow different highlightOptions to be used when calling highlight() method on layers in the ArcGIS API for JavaScript.

1306
6
11-23-2022 06:20 AM
mleahy_cl
New Contributor III

It would be helpful for some use cases to have the ability to pass different highlight options when calling a method like FeatureLayer.highlight(), such that features highlighted by that specific call appear with a different style than the map/scene view's default highlight options.  Simple use case: reveal the feature related to a selected row in a list, where the list itself corresponds with a set of currently-highlighted features in the map (i.e., the feature for the selected row could be 'highlighted' with a different color).

Currently, as discussed/clarified in another post, the ArcGIS API for JavaScript only supports one set of highlight options per map/scene view.  A solution/workaround discussed in the same thread suggests using a separate graphics layer, or similar approach to display features in different ways (i.e., not using the 'highlight()' method).  However, depending on specific use cases, this can add notable code complexity and perhaps impact performance if many features/layers are involved.

If the ability to use different highlightOptions were to be implemented, and a given feature is included in multiple calls to highlight features on a layer, we could expect the last highlightOptions applied to override others (until its corresponding handle is removed).

6 Comments
UndralBatsukh
Status changed to: In Product Plan
 
AnneFitz

This was supported in 2D at version 4.26 
https://developers.arcgis.com/javascript/latest/4.26/ 

3D support is coming soon.

mleahy_cl

@AnneFitz - Thanks for the update.  I saw those release notes, and that is definitely helpful to be able to set different highlight options per layer.  However, the new feature that has been added at 4.26 doesn't fully address the problem I've described.

If the features I want to highlight are displayed in different layers, then it'll work.  However, I will re-articulate the simple use case I initially described, where this new feature will not quite help (or perhaps you can clarify what I might have misunderstood):

We may want to highlight multiple features (within a single layer) that correspond to a table of items...for example, showing a set of selected features.  As a user interacts with the items in that list, the features that correspond with items in the list would appear with a different highlight colour, while all other features related to items in the list remain highlighted in the original colour.  If all the features in this scenario are in the same layer, the new feature introduced at 4.26 doesn't seem to solve the problem.

Perhaps it's easer to think of how ArcGIS Pro does this for a single layer: open the attribute table for a layer, select some features in that layer, then set the attribute table to 'show selected records' (so that only the highlighted features are visible in the table).  Now selected a row in the attribute table.  All the selected features remain highlighted as cyan by default, but the individual row selected in the table will appears highlighted differently (using yellow) in both the attribute table and the corresponding feature in the map. (e.g., here is an example screenshot https://ibb.co/LQrtTzD)

Unless I have misunderstood what is possible with the new feature in 4.26, we cannot yet achieve this behaviour unless we use multiple layers.

UndralBatsukh

We have plans to add support for the feature you are requesting for. Hence, I changed the status of the idea to In Product Plan.

mleahy_cl

@UndralBatsukh - ok, that's great! 🎉

IbrahimE

@UndralBatsukh 

Is there any update on this. This is very critical to have, as it's common to allow the user to select a feature and also apply highlights when hovering over another feature - at the moment, there is no way to have 2 simultaneous highlight colors for the same layer. The only work-around is creating an overlapping layer and copying the graphic over (overlay layer) - this is not ideal due to performance issues.