Select to view content in your preferred language

Highlighting multiple features with ArcGIS SDK 4.24

555
2
Jump to solution
03-06-2023 12:21 AM
PhilJonesDGC
New Contributor II

We have a feature layer for streetlights in our local area. We want to use this to let people report issues about streetlights. Our code for our development feature layer is in this Pen: Streetlights: highlighting multiple features with ArcGIS SDK 4.24 (codepen.io)

We are looking to improve this in 3 ways (listed below). We had most of these working when using v4.26 but it turns out that we are limited to working in v4.24 because of a 3rd party dependency. This means that using highlightIds on the feature table isn't an option.

We're new to ArcGIS so we're on a steep learning curve but we've now spent a week trying a variety of different options without success so any help or suggestions would be gratefully received.

The improvements we want to add are:
1. Highlight multiple features on the map - currently only the most recently selected feature is highlighted even though all the selected features are in our basket array and the feature table.  
2. Use zoom instead of scale - we're currently using the latter because zoom doesn't appear to work with our view.
3. Allow users to add new features to the layer at the same time as selecting existing features - our current data is incomplete so we need to let people report issues with new and existing features at the same time.

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

For question 1: You can listen to FeatureTable's selection-changed event to achieve what you are describing. I updated codepen to listen to selection-changed event. I also update the hittest logic to only return results from the streets light layer by setting the include parameter. I also updated it to highlight all overlapping features. https://codepen.io/U_B_U/pen/poOrPbj?editors=0010

For question 2. Please check out Zoom and LODs section in the MapView doc. Zoom is not working because of the behavior described in that section.

For question 3. You can use Editor widget with createWorkflow perhaps. Please check out this sample and re-purpose it? https://developers.arcgis.com/javascript/latest/sample-code/popup-editaction/ I tried FeatureLayer.applyEdits with Editor updateWorkflow but looks like your service does not support update. I ended up adding a few new features with null attributes. Hope that is OK. The codepen above has my quick test commented out.

 

Hope this helps,

-Undral 

View solution in original post

2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

For question 1: You can listen to FeatureTable's selection-changed event to achieve what you are describing. I updated codepen to listen to selection-changed event. I also update the hittest logic to only return results from the streets light layer by setting the include parameter. I also updated it to highlight all overlapping features. https://codepen.io/U_B_U/pen/poOrPbj?editors=0010

For question 2. Please check out Zoom and LODs section in the MapView doc. Zoom is not working because of the behavior described in that section.

For question 3. You can use Editor widget with createWorkflow perhaps. Please check out this sample and re-purpose it? https://developers.arcgis.com/javascript/latest/sample-code/popup-editaction/ I tried FeatureLayer.applyEdits with Editor updateWorkflow but looks like your service does not support update. I ended up adding a few new features with null attributes. Hope that is OK. The codepen above has my quick test commented out.

 

Hope this helps,

-Undral 

PhilJonesDGC
New Contributor II

Thanks Undral, 

I've now got my code working for questions 1 and 2. I haven't looked at the Editor widget yet but it's almost midnight so I'm going to leave that for tomorrow. If I run into any issues I'll ask it as a separate question.

Thanks again for pointing me in the right direction, much appreciated!

Cheers, Phil

0 Kudos