Select to view content in your preferred language

Remap Legend Labels - Dynamic Options?

163
0
a month ago
JasperRomero
Regular Contributor

Hello all,

I have a Web Map containing a Point Layer, with the symbology based on a field in that layer ("Stop_Number"). By default, the label in the Legend is just the value of the field that determines the symbology, i.e. Stop_Number - so in this case, stops are labeled things like 1, 2, 3, etc.

I want to programmatically change the labels in the Legend to pull values from another field, "Title". From what I have found so far, it should be possible to do this by modifying the renderer portion JSON layer definition: I will access the feature layer, create a dictionary mapping Stop_Number values to their corresponding Title values, and then use that dictionary to change the value for the "label" key to have the Title text, based on a match with the "values" key (which holds Stop_Number). I am working on this process currently, but as far as I can tell, it should work.

However, this would require the script to be re-run each time the underlying layer is modified to have more points, or change the value for Title or Stop_Number on existing points.

I am wondering:

1) Does this JSON-based editing approach make sense? Am I on the right track with this?

2) Is there a better way to have this remapping done dynamically, i.e. to always be up to date whenever the Point layer is edited, without having to periodically re-run my script?

Thanks in advance for any insights or suggestions!

0 Kudos
0 Replies