AnsweredAssumed Answered

JS API 4.11 view.popup.open() not displaying feature attributes, only text literal

Question asked by jkirtz_synterra on Apr 30, 2019
Latest reply on Apr 30, 2019 by rscheitlin

I've created a statistics query tool that uses a Tabulator table to display the selected results. When the user clicks on a row it will zoom to the appropriate feature. See screenshot:

 

 

I'd also like to open the selected feature's popup when they click on it, and I've gotten it to work, however it will only display the text literal instead of the feature attributes. See screenshot:

 

 

Here is my code, rowClick is from Tabulator.

rowClick: function(e, row) {
            // WHEN ROW IS CLICKED, ZOOM TO SELECTED FEATURE
            app.activeView.whenLayerView(app.layerToBeQueried).then(function(layerView) {

                var query = app.layerToBeQueried.createQuery();
                query.where = "StationShortName = " + "'" + row._row.data.StationShortName + "'";
                query.outSpatialReference = app.activeView.spatialReference;
                query.returnGeometry = true;

                app.layerToBeQueried.queryFeatures(query).then(function(results) {
                    var selectedFeature = results.features[0];

                    app.activeView.goTo({
                        target: selectedFeature.geometry,
                        zoom: 20
                    });

                    app.activeView.popup.open({
                        location: selectedFeature.geometry,
                        content: selectedFeature.sourceLayer.popupTemplate.content[0].text
                    })
                });
            });
        },

 

I've tried creating a PopupTemplate + TextContent and it did the same thing. Can someone please tell me what I'm doing wrong?

 

Thanks,

 

-Justin

Outcomes