AnsweredAssumed Answered

Javascript API 4.3 unique rendering problem

Question asked by wbaiesri-ca-esridist Employee on May 15, 2017
Latest reply on May 16, 2017 by wbaiesri-ca-esridist

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? 

Outcomes