I have a feature layer and I am highlighting the feature of the feature layers on click. It is working fine.
Now what I want is, I want to change the background color / fill some color in that highlighted polygon feature.
Here is the code where I am highlighting the feature:
let highlight;
let highlightIds = [];
view.whenLayerView(districtLayer).then(function(layerView){
view.on("click", (event) => {
const params = {
location: event.mapPoint
};
locator.locationToAddress(serviceUrl, params).then(function(response) { // Show the address found
const district = response.attributes.Subregion;
// remove all highlights first
if(highlight) {
highlight.remove();
}
// check if district is already highlighted
let district_id = districtIds.indexOf(district) + 1;
if(highlightIds.includes(district_id)){
highlightIds.splice(highlightIds.indexOf(district_id), 1);
}else{
highlightIds.push(district_id);
}
// hightlight only the selected districts
highlight = layerView.highlight(highlightIds);
// code here to fill background color
}, function(err) { // Show no address found
console.log("No address found.", evt.mapPoint);
});
});
});