1

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?

1 Answer 1

0

The outFields property on the feature layer needs to be set to provide the desired fields before accessing the hitTest results.

Using a wildcard to enable all fields:

var layer = jmv.view.map.layers.getItemAt(0)
layer.outFields = ["*"]

// hitTest code below

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.