Select to view content in your preferred language

How to get attributes of Web Map feature which user clicked on in custom widget in ArcGIS Experience Builder application?

513
2
Jump to solution
05-11-2023 04:08 PM
work2023
New Contributor

I have an ArcGIS Experience Builder application, which uses a Web Map I host in ArcGIS online. This Web Map contains a feature layer with several attributes, and I can use these in Experience Builder with the stock widgets (i.e. updating dynamic text based on attributes when the user clicks on a certain feature). I am now trying to write a custom widget using Jimu which displays some text when the user clicks on a feature:

      jmv.view.on('click', evt => {
        const point: Point = jmv.view.toMap({
          x: evt.x,
          y: evt.y
        })

        jmv.view.hitTest(evt).then((response) => {
          console.log(response.results[0].graphic.attributes)
          // Do things with the attributes of the clicked feature
        })
      })

However, this code only returns the `ObjectID` attribute of the clicked feature, and none of the others. How do I access the rest of the features?

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You have to add the fields you want to see in the feature layer's outFields property. It defaults to null, only returning the Object ID field

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

You have to add the fields you want to see in the feature layer's outFields property. It defaults to null, only returning the Object ID field

0 Kudos
work2023
New Contributor

Excellent, thank you!

0 Kudos