I'm trying to create a feature for my app in AppStudio 4 where if the user clicks on one of the points on the given map, the map extent and zoom will change to center the selected point. I can't figure out how to do this. Here's my code and explanations:
I'm pulling the coordinates with a http request remotely. As the data gets updated, the points will update themselves. I was able to get this working fine. Inside my http request, for each data record, I use PointBuilder to create points and graphics on the map. See below:
<SPAN class="keyword token">var</SPAN> sr <SPAN class="operator token">=</SPAN> ArcGISRuntimeEnvironment<SPAN class="punctuation token">.</SPAN><SPAN class="token function">createObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"SpatialReference"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> wkid<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">4326</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> pointBuilder <SPAN class="operator token">=</SPAN> ArcGISRuntimeEnvironment<SPAN class="punctuation token">.</SPAN><SPAN class="token function">createObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"PointBuilder"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
pointBuilder<SPAN class="punctuation token">.</SPAN>spatialReference <SPAN class="operator token">=</SPAN> sr<SPAN class="punctuation token">;</SPAN>
pointBuilder<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setXY</SPAN><SPAN class="punctuation token">(</SPAN>record<SPAN class="punctuation token">.</SPAN>long<SPAN class="punctuation token">,</SPAN> record<SPAN class="punctuation token">.</SPAN>lat<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> geom <SPAN class="operator token">=</SPAN> pointBuilder<SPAN class="punctuation token">.</SPAN>geometry<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>geom<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> graphic <SPAN class="operator token">=</SPAN> ArcGISRuntimeEnvironment<SPAN class="punctuation token">.</SPAN><SPAN class="token function">createObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Graphic"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> geometry<SPAN class="punctuation token">:</SPAN> geom <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
graphicsOverlay<SPAN class="punctuation token">.</SPAN>graphics<SPAN class="punctuation token">.</SPAN><SPAN class="token function">append</SPAN><SPAN class="punctuation token">(</SPAN>graphic<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>record refers to each data point I'm pulling with the http request.
This works fine and I'm able to view my points on the map. But now, I want to click or tap on the point graphic and have it respond, for instance by centering the map on the selected point. Seems like pretty basic map-component interaction behavior. But I can't find much documentation on this. How can I go about doing this?
Any ideas appreciated. Thanks!