Values of domains using hitTest

509
1
09-15-2021 07:37 AM
Vakhtang_Zubiashvili
Occasional Contributor III

Hello there,

 

I aim using hitTest to get values of features that i have on my map and show them in my HTML  table i do it so: 

graphic.attributes.qselis_kategoria; After this i try to add name, values, alias but nothing works. How can i get values of domains? Help
0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor

There are few a steps to something like this.

The layer has a fields property

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields

Looking at the field, it has a domain property

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html

Domain could be range or codedValue type

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#domain

CodedValue has a method called getName that I think will do what you are looking for.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.h...

Which could end up looking like this.

const field = layer.fields.find((field) => field.name === FIELD_NAME);
const domain = field.domain;
const domainValue = field.getName(attributes[FIELD_NAME]);

 

I think, I haven't had to do something like this in a while, but that should get you on the right track.

0 Kudos