Accessor#set Assigning an instance of 'esri.Graphic' which is not a subclass of 'esri.Graphic'

363
4
01-24-2021 10:57 PM
agsdaniel
New Contributor
var GraphicsLayer = GraphicsLayer.createSubclass({
            declaredClass:"egova.layers.GraphicsLayer",
...
addGraphic:function (idlayerTaggeometrystyleattr,
                    hStylepopupTemplate) {
                var graphic = new Graphic({geometry:geometry});
                this.setSymbol(graphic,style);
                graphic.style = style;
                graphic.attributes = attr;
                graphic.id = id;
                graphic.hStyle = hStyle;
                graphic.layerTag = layerTag;
                graphic.extent = geometry.extent;
                popupTemplate&&(graphic.popupTemplate = popupTemplate);
                
                this.add(graphic);
                return graphic;
            }
});

when to add a graphic to graphicslayer,console prints the errors"Accessor#set Assigning an instance of 'esri.Graphic' which is not a subclass of 'esri.Graphic'",what's the problem?

Tags (1)
0 Kudos
4 Replies
agsdaniel
New Contributor

arcgis api for js version is 4.18.0

0 Kudos
VictorBerchet
New Contributor III

It's hard to figure out with so little information. The best would be for you to add a reproduction in a codepen as https://codepen.io/vicb-the-lessful/pen/wvzLEBa?editors=100

Maybe

 

var GraphicsLayer = GraphicsLayer.createSubclass({
            declaredClass:"egova.layers.GraphicsLayer",

 

looks fishy: try to change the variable name to something different than the base class, i.e. `ExtendedGraphicsLayer` ?

0 Kudos
agsdaniel
New Contributor

https://codepen.io/xstrivefor/pen/YzGommX

the error doesn't  repeat in codepen,but the same code will print the error every time when to use method addGraphic in local enviroment

agsdaniel_0-1611641366474.png

 

0 Kudos
agsdaniel
New Contributor

The problem hasn't been solved.Maybe the inheritance has a problem in strict mode.Is there anynone has a solution?

agsdaniel_2-1611822746122.png

 

0 Kudos