[GIS] Getting value coded of domain from map layer with arcgis javascript api

arcgis-javascript-apidomainsjavascript

I'm trying to read domain values on a map, how to achieve this objective in arcgis javascript api? any help?

Best Answer

You can get this from the FeatureLayer class. There is an attribute called fields, which is an array of Field objects. The Field class has domain attribute.

The following will output the domains in the console (if any):

var map = new Map(...);
var fl = new FeatureLayer(...);
map.addLayer(fl);

// when layer is ready
fl.on("load", ()=>{
   for (var i = 0; i < fl.fields.length; i++) {
     console.debug(fl.fields[i].domain);
   }
});

Good luck!