0

I'm using ArcGIS JavaScript API to display a map with a feature layer with multiple records.enter image description here

I wrote code to display a pop up when a record is selected on the map. Is it possible to change the color of the selected record to some other color by updating the renderer when its clicked on and persist the change?

I know the Javascript Api highlights the boundary when a record is clicked on but it doesnt persist, when another record is clicked the previous clicked record go backs to its original color.

2
  • 1
    You can use the map's graphics layer and define your own renderer. The features will persist until you remove them.
    – crmackey
    Commented Jun 5, 2018 at 4:10
  • Do i need to pass the geometry of the record to the graphics layer?
    – Ravi
    Commented Jun 5, 2018 at 17:45

1 Answer 1

1

If you're using the version 4.x ArcGIS API for JavaScript, you can use the highlight functionality. Here is a demo (click on a feature).

3
  • Awesome thank you. I'm not using 4.x version but ill upgrade for this very feature.
    – Ravi
    Commented Jun 6, 2018 at 19:06
  • In the 3.x version it should be easier - you want to add an extra FeatureLayer but make it in MODE_SELECTION and then onClick add or remove the feature from being "selected".
    – GavinR
    Commented Jun 7, 2018 at 14:38
  • When i just use your jsfiddle and update feature layer URL, the highlight feature isn't working. Do i need edit any of my FeatureServer properties?
    – Ravi
    Commented Jun 7, 2018 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.