let layer = new FeatureLayer({
portalItem: { id: "5ce5374a461e45bab714b43ffedf151d" }
});
uniqueValues({
layer: layer,
field: "Candidate"
}).then(function(response){
// prints each unique value and the count of features containing that value
let infos = response.uniqueValueInfos;
infos.forEach(function(info){
console.log(info.value);
});
});
I'm struggling on how to store the info.value into a new Array
Solved! Go to Solution.
let layer = new FeatureLayer({
portalItem: { id: "5ce5374a461e45bab714b43ffedf151d" }
});
uniqueValues({
layer: layer,
field: "Candidate"
}).then(function(response){
let infos = response.uniqueValueInfos;
const values = infos.map((info) => info.value);
});
Just call Array.map() and return the value in the callback. That will create a new array with only the values.
let layer = new FeatureLayer({
portalItem: { id: "5ce5374a461e45bab714b43ffedf151d" }
});
uniqueValues({
layer: layer,
field: "Candidate"
}).then(function(response){
let infos = response.uniqueValueInfos;
const values = infos.map((info) => info.value);
});
Just call Array.map() and return the value in the callback. That will create a new array with only the values.