Spatially Query a FeatureLayer and pass the outFields to a JS variable

360
0
02-03-2021 06:16 PM
Imagomundi
New Contributor

#firstPost

I'm trying to spatially query a featureLayer and pass the outFields to a JS variable for use in other HTML elements. I've explored "esri/tasks/support/Query", "availableFields" and tried extracting data from elements like the popupTemplate (as macgyver as that is). Im not sure if Arcade is involved and if so maybe throwing me off. 

For example, this code defines the popupTemplate element and that it will display fields "B12001_calc_pctMarriedE" and "B12001_calc_numMarriedE" from all the fields `["*"]`. I'm looking to pass these variables to a JS variable. Im not sure where I should be scooping this information up. and how to go about it.

 

var popupTemplate = new PopupTemplate({
  // autocasts as new PopupTemplate()
  title: "{NAME} in {COUNTY}",
  outFields: ["*"],
  content: [{
    // It is also possible to set the fieldInfos outside of the content
    // directly in the popupTemplate. If no fieldInfos is specifically set
    // in the content, it defaults to whatever may be set within the popupTemplate.
    type: "fields",
    fieldInfos: [{
      fieldName: "B12001_calc_pctMarriedE",
      label: "Married %"
    },{
      fieldName: "B12001_calc_numMarriedE",
      label: "People Married",
      format: {
        digitSeparator: true,
        places: 0
      }
    }]
  }]
});

 

 

Thank you in advance!

Tags (2)
0 Kudos
0 Replies