How to get points created using PointBuilder QML Type to listen to click events?

793
2
Jump to solution
10-10-2019 11:10 AM
KevinCheriyan
Occasional Contributor

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:

var sr = ArcGISRuntimeEnvironment.createObject("SpatialReference", { wkid: 4326 });
var pointBuilder = ArcGISRuntimeEnvironment.createObject("PointBuilder");
pointBuilder.spatialReference = sr;
pointBuilder.setXY(record.long, record.lat);
var geom = pointBuilder.geometry;
if (geom) {
         var graphic = ArcGISRuntimeEnvironment.createObject("Graphic", { geometry: geom });
         graphicsOverlay.graphics.append(graphic);
         }

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

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!


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
1 Solution

Accepted Solutions
KevinCheriyan
Occasional Contributor

I found this example from the esri team on github. You solve this issue by calling identifyGraphicsOverlay on the MapView.


--------------------------------------------------
Application Developer, GeoMarvel

View solution in original post

0 Kudos
2 Replies
KevinCheriyan
Occasional Contributor

I found this example from the esri team on github. You solve this issue by calling identifyGraphicsOverlay on the MapView.


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
ErwinSoekianto
Esri Regular Contributor
0 Kudos