AnsweredAssumed Answered

Get Feature Layer Attributes for variable

Question asked by DamienRobinson on Sep 12, 2014
Latest reply on Sep 15, 2014 by DamienRobinson

Hi,

 

I am working on a system by where a user can click a point on a map and this passes several variables to a form for submission. I have successfully pulled the XY coordinates from the click event into the form, using the following lines of code:

 

  x = evt.geometry.x.toFixed(3);
  y = evt.geometry.y.toFixed(3);

 

 

However a new requirement means I have to pull an ID (an attribute in a feature layer) on click. I've been searching through the JS API but none of the examples seem to cover this topic. There is plenty covering popups, queries, identify tasks etc., for displaying the infromation, however I want to simply pass it as a variable, similar to the the x and y variables above.

 

I intially looked at the infotemplate function, as a simple substitution variable seems to populate the correct information.

 

e.g.

 

var content = "<br><b>Test ID</b>: ${Test_ID}"
var infotemplate = new esri.InfoTemplate(); 
infotemplate.setContent(content); 

 

I don't know if it's possible to utilise the substitution variable (${Test_ID}) to pass the attribute to a form?

 

I've looked at the query and identify tasks however these return objects that I can't seem to pass the results of as a variable.

Outcomes