How to get the clicked graphic(or a feature) in a graphicslayer(or a featurelayer) using runtime sdk for .ne

3628
2
05-13-2015 09:19 AM
JohnWoon
New Contributor

I would like to obtain informations(the instance) of the clicked feature in a feature layer.

In runtime for wpf we have the MouseLeftButtonDown event provided by the graphicslayer class. The event will pass the clicked instance, but not a equivalent one could be found in runtime for .net.

0 Kudos
2 Replies
AnttiKajanus1
Regular Contributor II

You can use MapViewTapped event (or Editor class) to get location and then use Layer's HitTestAsync method to get graphics from the layer.

See sample HitTesting​ or equivalent for GraphicsLayers / Overlays.

0 Kudos
JohnWoon
New Contributor

HitTesting only returns an array of the feature ids, not graphics. And I am not quite sure, but it seems "var features = await cities.FeatureTable.QueryAsync(rows);"  may re-query the server.

I tried a similarly way before, and I found that I could retrieve more attributes than the outfields I defined before.

I there a possible way to query locally cached data? So it may speed up.

0 Kudos