Skip to main content
answer improvements
Source Link

I don't understand why you use functions async way, but there is an example in the documentation.

HitTest sample


view.on("pointer-down", eventHandler);
function eventHandler(event) {
  view.hitTest(event).then(function (response) {
    if (response.results.length) {
      const graphic = response.results[0].graphic;
      const attributes = graphic.attributes;
      console.log(attributes);
    }
  });
}

If FeatureLayer' features have attributes and you want to get all attributes, you should define outFields property as ["*"].

const layer = new FeatureLayer({
  // URL to the service
  url: "url,
  outFields: ["*"]
});

OR

featureLayer.outFields = ["*"];

I don't understand why you use functions async way, but there is an example in the documentation.

HitTest sample


view.on("pointer-down", eventHandler);
function eventHandler(event) {
  view.hitTest(event).then(function (response) {
    if (response.results.length) {
      const graphic = response.results[0].graphic;
      const attributes = graphic.attributes;
      console.log(attributes);
    }
  });
}

I don't understand why you use functions async way, but there is an example in the documentation.

HitTest sample


view.on("pointer-down", eventHandler);
function eventHandler(event) {
  view.hitTest(event).then(function (response) {
    if (response.results.length) {
      const graphic = response.results[0].graphic;
      const attributes = graphic.attributes;
      console.log(attributes);
    }
  });
}

If FeatureLayer' features have attributes and you want to get all attributes, you should define outFields property as ["*"].

const layer = new FeatureLayer({
  // URL to the service
  url: "url,
  outFields: ["*"]
});

OR

featureLayer.outFields = ["*"];

Source Link

I don't understand why you use functions async way, but there is an example in the documentation.

HitTest sample


view.on("pointer-down", eventHandler);
function eventHandler(event) {
  view.hitTest(event).then(function (response) {
    if (response.results.length) {
      const graphic = response.results[0].graphic;
      const attributes = graphic.attributes;
      console.log(attributes);
    }
  });
}