Click Event on graphics

3373
1
12-07-2014 02:00 AM
shafitrumboo
New Contributor III

1. Want to add feature layer (point) on map

2. On click of feature (graphics) open a pop-up window with information but I have lot of information like relational information probally will show in three tabs

3. User should be able to enter new point feature with attributes also

Question

  1. Can we implement it like in JavaScript and flex API'S where we can attach click event handler to graphics
  2. But it seems we have to listen setOnSingleTapListener which is com.esri.android.map.event
Tags (2)
0 Kudos
1 Reply
DavidMartin
Occasional Contributor II

Your assumption seems right to me - that you need to capture touch events at the level of the map. To me, this makes good logical sense, in that you can't tap a layer as such - only the map as a whole. The current state of the app (e.g. whether a "select graphic" tool is enabled) will determine whether a particular layer should respond.

If your app is relatively simple, you could drop all your logic in the MapView's OnSingleTapListener (or other listener for different touch events).

Alternatively, you could extend GraphicsLayer or FeatureLayer and drop the logic for each type of layer in your app into a new method (e.g. OnSingleTap?). The MapView's OnSingleTapListener could then call each layer's OnSingleTap method, and depending on your layer's current state (which might depend, say, on which tools or options are enabled), each layer could work out what it needs to do (if anything) in respond to the tap.

A GraphicsLayer can use the following methods to get the graphic(s) nearest to a tapped point:

getGraphicIDs (has various overrides that allow you to specify tolerance and max number of results returned)

getGraphic(int uid) - allows you to get the actual instance of a Graphic, given any of the IDs returned above.

0 Kudos