trying2drawlinebetween2points

Pass custom field variable into pop-up

Discussion created by trying2drawlinebetween2points on Jul 7, 2020
Latest reply on Jul 9, 2020 by trying2drawlinebetween2points

I am trying to add one new pop-up field, that comes from a separate rest call, but I am unsure how to incorporate.

 

All my other fields come from this service:

 

https://services9.arcgis.com/RHVPKKiFTONKtxq3/ArcGIS/rest/services/USGS_Seismic_Data_v1/FeatureServer/1/ 

 

But I need one piece of data from this service, the 'name' as place (which I am getting and using fine, I just can't get it into the pop-up):

 

https://services9.arcgis.com/RHVPKKiFTONKtxq3/ArcGIS/rest/services/USGS_Seismic_Data_v1/FeatureServer/0/ 

 

With my original query, I add this to get the name (or place) from second service:

 

                let plc;
                 ............
                QTt.execute(query2).then(function(results) {
                    results.features.map(function(feat) {
                        let magD = feat.attributes["id"];
                        if (id === magD) {
                            plc = feat.attributes["place"];
                             .......................

 

And below is my attempt to call it into the pop-up:

 

          function popupContent (feature) {
                const div = document.createElement('div');
                div.innerHTML =
                "<span class='name_plc'>Name: "+ plc + "</span>"; <------------ attempt
                return div;
            }
            let popuptemp = {
                title: "Shake Intensity",
                content: [{
                    type: "fields",
                    fieldInfos: [{
                            fieldName: "grid_value",
                            label: "Grid Value"
                        },
                        {
                            fieldName: "id",
                            label: "id"
                        },
                        {
                            fieldName: "place",
                            label: "place"
                        },
                        {
                            fieldName: "ObjectID",
                            label: "ObjectID"
                        },
                        {
                            fieldName: "url",
                            label: "Url"
                        }
                    ]
                }]
            }
            fl = new FeatureLayer({
                source: gras,
                objectIdField: "ObjectID",
                geometryType: "polygon",
                fields: [{
                        name: "ObjectID",
                        alias: "ObjectID",
                        type: "oid"
                    }, {
                        name: "id",
                        alias: "id",
                        type: "string"
                    },
                    {
                        name: "place",
                        alias: "place",
                        type: "string"
                    },
                    {
                        name: "url",
                        alias: "url",
                        type: "string"
                    }, {
                        name: "grid_value",
                        alias: "grid_value",
                        type: "double"
                    }
                ],
                renderer: renderer,
                popupEnabled: true,
                popupTemplate: popuptemp,
                content: popupContent, <--- attempt
            });

            app.mapview.map.add(fl);

Outcomes