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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked May 11, 2023 at 23:04

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
answered May 12, 2023 at 17:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.