I have a simple map service API that serves a grid feature and I want to grab an attribute ("Grid_Cell2") that has the grid cell name when the user clicks a button. The grid feature has start and end points (x, y) for each cell and a field called "Grid_Cell2" which is basically the grid cell name (ex: "Grid_Cell49_19"). I am already capturing my x, y for the mouse click on the map in my application. The examples I have seen for IdentifyTask and IdentifyParameters generally show the .executefor the IdentifyTask method being launched when the user clicks on the map (ex:map.on("click", executeIdentifyTask);`) and then populating a popup. I only want to grab the desired feature based on the users x, y (which I have already captured in a variable) when the user clicks the button. Assume I have already added the required module and function and initialized the function at the top:
document<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getElementById</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"btnGetInterval"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>onclick <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> point <SPAN class="operator token">=</SPAN> additionalInfo<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"pointGeomOfInterest"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//this is an x, y coordinate captured earlier in my code from the user's mouse click on the map</SPAN>
identifyTask <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">IdentifyTask</SPAN><SPAN class="punctuation token">(</SPAN>grid_url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
identifyParams <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">IdentifyParameters</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
identifyParams<SPAN class="punctuation token">.</SPAN>geometry <SPAN class="operator token">=</SPAN> point<SPAN class="punctuation token">;</SPAN>
identifyParams<SPAN class="punctuation token">.</SPAN>returnGeometry <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//I don't want to return any geometry</SPAN>
identifyParams<SPAN class="punctuation token">.</SPAN>layerOption <SPAN class="operator token">=</SPAN> IdentifyParameters<SPAN class="punctuation token">.</SPAN>LAYER_OPTION_ALL<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//Not sure about this. I just want to return the one feature for the grid cell whose boundaries my user's mouse click (x, y) falls within....</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>From here, I'm honestly not sure where to go; I assume I want to use a .execute statement but I am not sure how the `IdentifyParameters come into play. I also may need an empty var/array/list to hold the returned value (["Grid_Cell2"]). Any suggestions here?