Adding a feature layer programmatically in Webapp builder edit widget

343
0
05-18-2020 06:44 AM
DávidGregor
New Contributor II

I know this question's scope is bigger than some lines of code, but maybe somebody did this already.

We have like 40 webmap's and i'm trying to add the editable feature layer with the edit widget, because it's just an error reporting layer, so the user doesn't really need to see it all the time. I configured the edit widget with it's config, i see the printed parameters, if i open the widget. 

Any idea what i missed? 

This is how i load it:

      addErrorReportLyr: function(){
        var featureLayer = new FeatureLayer("https://hostname.local/arcgis/rest/services/errorReports/FeatureServer/0"
        {id:"errorReports"});

        this.map.addLayer(featureLayer); 
        console.log('addlayer');
        

        featureLayer.on('load'lang.hitch(thisfunction() {

          LayerInfos.getInstance(this.mapthis.map.itemInfo).then(lang.hitch(thisfunction(layerInfos) {

            var featureLayerInfo = layerInfos.getLayerInfoById(featureLayer.id);
            featureLayerInfo.title = '';

            featureLayerInfo.loadInfoTemplate().then(lang.hitch(thisfunction() {

            console.log(featureLayerInfo);

            }));

          }));

        }));
      },

And how i call it(i know it's not nice, but has to be first i think):

 
     _prepareCreating: function() {

        // beginEditingByFeatures can be called from outside,
        // so _init must be called before userDef resolved.
        this.addErrorReportLyr();
        this._init();
        
        this.loading.show();
  1. allowCreate: true                   //This is my print from _getLayerInfosConfig 
  2. allowDelete: true
  3. disableGeometryUpdate: false                         
  4. featureLayer: {id: "errorReports"}//my current map's print btw: graphicsLayerIds: (2) ["graphicsLayer1", "errorReports"]
  5. fieldInfos: (5) [{…}, {…}, {…}, {…}, {…}]
  6. __proto__: Object
  • length: 1
  • __proto__: Array(0)
_getLayerInfosInConfig: function() {
...
else if(this._configEditor.layerInfos.length > 0)  {
          // configured and has been checked.
          //layerInfos = this._getDefaultLayerInfos();
          layerInfos = this._converConfiguredLayerInfos(this._configEditor.layerInfos);
          console.log("3",layerInfos);
0 Kudos
0 Replies