AnsweredAssumed Answered

How to populated Attribute table from map layer (not url)

Question asked by franklin.alexander on Apr 28, 2020
Latest reply on Apr 28, 2020 by rscheitlin

I have been trying to figure out how the Attribute table widget gets the data for populating the table. I have a simple app showing a layer pulled into the map using an ajax call to appery.io API, then displayed in the map using the following code:

var layerDefinition = {
                         "geometryType": "esriGeometryPoint",
                         "fields": fielddefs
                    //"maxScale": 72223.819286
                    }

                    var QueryGraphics = [];
                    for(var i = 0; i < FormattedResults.data.length; i++) {
                         var attr = FormattedResults.data[i];
                         //Build Graphic
                         var graphicComp = new esri.geometry.Point(attr["lng"], attr["lat"], new esri.SpatialReference({ wkid: 4326 }))//4326 GCS_WGS_1984
                         var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 10,
                              new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
                              new dojo.Color([255,255,255]), 1), new dojo.Color([255,0,0]));
                         var template = new esri.InfoTemplate();
                    if(window.appInfo.isRunInMobile) {
                        template.setTitle("Gopher Tortoise Sighting");
                    } else {
                        template.setTitle(false);
                    }

                         template.setContent(
                              this.getWindowContent
                         );

                         var pointGraphic = new esri.Graphic(graphicComp, symbol, attr, template)
                    //console.log("photographer: ", pointGraphic.attributes.name)
                         QueryGraphics.push(pointGraphic);

                    }
        window.featureSet = QueryGraphics;
                    var QueryfeatureSet = new esri.tasks.FeatureSet();
                    QueryfeatureSet.features = QueryGraphics;
                    QueryfeatureSet.geometryType = "esriGeometryPoint";
                    QueryfeatureSet.spatialReference = new esri.SpatialReference({ wkid: 4326 });
        //console.log("query featureset ", QueryfeatureSet);
                    var featureCollection = {
                         layerDefinition: layerDefinition,
                         featureSet: QueryfeatureSet
                    };

                    var gtLayer =     new esri.layers.FeatureLayer(featureCollection, {
                         id: "GopherTortoiseQuery",
                         opacity: 0.6,
                         infoTemplate: template,
                         outFields: ["*"]
                    });

                    gtLayer.name = "GopherTortoiseQuery";
                //console.log("search result ", gtLayer);
                    //Add Map Render
                    renderer = new esri.renderer.SimpleRenderer(symbol);
                    gtLayer.setRenderer(renderer);
        gtLayer.capabilities = "Map,Query,Data";
                    //Add Layer to Map
        this._CleanUpGopherTortoise();
                    this.map.addLayer(gtLayer);
        let map = this.map;
        gtLayer.on("load", function() {
          let gtExt = graphicsUtils.graphicsExtent(gtLayer["_graphicsVal"]);
          //console.log("gt layer extent ", gtExt);
          gtLayer.initialExtent = gtExt;
          gtLayer.fullExtent = gtExt;
          map.setExtent(gtExt, true);
          //console.log("gopher tortoise layer ", gtLayer);
        })

 

The problem is the Attribute table won't populate. It partially loads and doesn't throw any errors:

 

 

Also, the div isn't fully loading (the tab is missing) which suggests to me the code is hanging up some place, I just haven't been able to figure out where. When logging the config infos, the url is missing because I am not pulling in the layer from ArcGIS REST, so could that be the issue? If so how can I get the data to load from graphics layer and not from the url? I have been trying to find the correct function that I need to revise to do this, but have been unable to do so. 

 

I know the issue has to do with the layer or the url, because I set up a test app with point data referenced from ArcGIS REST and compared the two apps and cannot find any differences in any of the log statements, other than the missing url and the fact that the data is missing from the domNode (innerText)

 

I can provide additional info if needed and thanks ahead for any suggestions. Basically If I know which function I need to be in, I can figure it out! 

Outcomes