Renderer is not a function

283
1
08-08-2019 04:56 AM
FelixEscalas
New Contributor II

Hello all!

I have a problem with this code. The renderer give me an error.  Anyone can help me?

Thanks in advance. 



_onExecuteClick2: function(){
var field= dojo.byId('actualFieldSelect').value
var capa1
var layers = this.map.getLayersVisibleAtScale(5000);
array.forEach(layers,function(layer){
//console.info(datasel)
if (layer.name="Qualitat " + datasel) {
capa1=layer
var line = new SimpleLineSymbol();
line.setStyle(SimpleLineSymbol.STYLE_NULL);
var symexcel = new SimpleMarkerSymbol( {
"color":[0, 255, 0, 1],
"type": "esriSMS",
"outline":{"width":0},
"size":15,
"style":"esriSMSCircle"});
var symbona = new SimpleMarkerSymbol( {
"color":[0, 255, 0, 1],
"outline":{"width":0},
"type": "esriSMS",
"size":15,
"style":"esriSMSCircle"});
var symregular = new SimpleMarkerSymbol( {
"color":[0, 255, 0, 1],
"outline":{"width":0},
"type": "esriSMS",
"size":15,
"style":"esriSMSCircle"});
var symdolenta = new SimpleMarkerSymbol( {
"color":[0, 255, 0, 1],
"outline":{"width":0},
"type": "esriSMS",
"size":15,
"style":"esriSMSCircle"});
var renderer = {
type: "class-breaks",
field: field,
classBreakInfos: [
{
minValue: 125,
maxValue: 99999,
symbol: symdolenta,
label: "Dolenta"
}, {
minValue: 83,
maxValue: 126,
symbol: symregular,
label: "Regular"
}, {
minValue: 42,
maxValue: 82,
symbol:symbona,
label: "Bona"
}, {
minValue: -Infinity,
maxValue: 81,
symbol:symexcel,
label: "Excelents"
}
]
};

capa1.setRenderer(renderer);
capa1.refresh()
}
});
},

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Esteemed Contributor

Felix,

   It looks like you are combining JS API 3.x and 4.x code... In 3.x you define a Classbreak render this way:

var renderer = new ClassBreaksRenderer(symbol, "POP07_SQMI");
        renderer.addBreak(0, 25, new SimpleFillSymbol().setColor(new Color([56, 168, 0, 0.5])));
        renderer.addBreak(25, 75, new SimpleFillSymbol().setColor(new Color([139, 209, 0, 0.5])));
        renderer.addBreak(75, 175, new SimpleFillSymbol().setColor(new Color([255, 255, 0, 0.5])));
        renderer.addBreak(175, 400, new SimpleFillSymbol().setColor(new Color([255, 128, 0, 0.5])));
        renderer.addBreak(400, Infinity, new SimpleFillSymbol().setColor(new Color([255, 0, 0, 0.5])));