Hi,
I'm trying to implement a function that allows to click a polygon to change its rendering. Here is my code.
this.view.on("click", function(evt){
var point = {
x:evt.x,
y:evt.y
};
this.view.hitTest(point).then(function(response){
var graphic = response.results[0].graphic;
var id= graphic.attributes.SITE_ID; // get the unique id for special rendering
var lyr = graphic.layer;
var render = new Renderer({
field: "SITE_ID",
defaultSymbol: lyr.renderer.symbol || lyr.renderer.defaultSymbol,
uniquevalueInfos:[{
value: id,
symbol: new SimpleFillSymbol({
color: [ 51,51, 204, 0.9 ],
style: "solid",
outline: {
color: "white",
width: 1
}
})
}]
});
lyr.renderer=render;
});}.bind(this));
The code runs fine without any error happen, and I also get the legend changed, but the rendering of that polygon does not change at all. Does anyone have the same issue?
Yunpaio,
So I assume you have seen this sample, since your code looks like it was based on this:
Access features with click events | ArcGIS API for JavaScript 4.3
I have not had your issue. Can you share you complete code for inspection?
It also looks like you're calling `new Renderer()` when it should be `new UniqueValueRenderer()`
Robert and Kristian,
Thank you both for the reply. I've found the problem, which is pretty dumb. It is because I did not capitalize 'V' for 'uniquevalueInfo' .
Again, thanks for the answer.