I am in the process of creating my first custom 2 D widget and I can dynamically add a layer on the map , but as soon as I try to add a renderer to override the symbology coming from the map service then the layer does not show on the Layer List anymore and I get no error message
Here is my environment:
- Portal for ArcGIS version 10.6
- Web AppBuilder Developer Edition 2.6
- ArcGIS JavaScript API 3.33
Here is part of my code: as soon as I had the lines in bold then the layer does not show anymore:
I have defined:
define(['dojo/_base/declare',
'jimu/BaseWidget',
'dojo/on',
'esri/layers/FeatureLayer',
'esri/renderers/SimpleRenderer',
'esri/symbols/PictureFillSymbol',
'esri/Color',
'esri/map',
'esri/dijit/Legend'
],
function(declare,
BaseWidget,
on,
FeatureLayer,
SimpleRenderer,
SimpleFillSymbol,
Color,
Map)
{
//To create a widget, you need to derive from BaseWidget.
return declare([BaseWidget],
{
baseClass: "test",
..........
_onBtnTestClicked: function()
{
var comp1 = test1.value;
var template = new esri.InfoTemplate();
var comp1OperatorLayerURL = "https://........";
var comp1OperatorfeatureLayer = new esri.layers.FeatureLayer(comp1OperatorLayerURL, {
id: comp1Operator,
outFields: ["*"],
opacity: 0.5,
infoTemplate: template,
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
definitionExpression: comp1OperatorSearch
});
comp1OperatorfeatureLayer._titleForLegend=comp1OperatorfeatureLayer.title=comp1OperatorfeatureLayer.name=comp1Operator;
// set the symbology
var symbol = new esri.symbol.SimpleFillSymbol().setColor(new esri.Color([255,0,0,0.5]));
var renderer = new SimpleRenderer(symbol);
comp1OperatorfeatureLayer.setRenderer(renderer);
......
map.addLayers([comp12NonOperatedOVOperatedfeatureLayer,...]);
......
Solved! Go to Solution.
Michel,
You have:
define([
'dojo/_base/declare',
'jimu/BaseWidget',
'dojo/on',
'esri/layers/FeatureLayer',
'esri/renderers/SimpleRenderer',
'esri/symbols/PictureFillSymbol',
'esri/Color',
'esri/map',
'esri/dijit/Legend'
],
function(declare,
BaseWidget,
on,
FeatureLayer,
SimpleRenderer,
SimpleFillSymbol,
Color,
Map)
{
Michel,
You have:
define([
'dojo/_base/declare',
'jimu/BaseWidget',
'dojo/on',
'esri/layers/FeatureLayer',
'esri/renderers/SimpleRenderer',
'esri/symbols/PictureFillSymbol',
'esri/Color',
'esri/map',
'esri/dijit/Legend'
],
function(declare,
BaseWidget,
on,
FeatureLayer,
SimpleRenderer,
SimpleFillSymbol,
Color,
Map)
{
Thank you Robert,
So I understood the documentation right, I just entered the wrong widget.
Sorry about that!