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.

asked Jun 4, 2018 at 20:15
2
  • 1
    You can use the map's graphics layer and define your own renderer. The features will persist until you remove them. Commented Jun 5, 2018 at 4:10
  • Do i need to pass the geometry of the record to the graphics layer? 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).

answered Jun 6, 2018 at 4:47
3
  • Awesome thank you. I'm not using 4.x version but ill upgrade for this very feature. 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". 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? Commented Jun 7, 2018 at 17:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.