Hi Raz,
is this thing possible?
any suggestions on how to approach the problem?
Indeed it is possible. I would try something like this:1. Use the setOnSingleTapListener method on the MapView to find out when a user taps on the map. In that method you will be passed a location in pixels (x and y parameters). 2. Pass these to the getGraphicIds method on the GraphicsLayer that you have, and this will find the unique IDs of the nearest graphics. You may want to experiment with the different overloads of this method - you can choose different tolerance distances for the tap location, and limit the number of results returned. 3. From that graphic ID that gets returned, you can then use the GraphicLayer.getGraphic method, to return the Graphic that was tapped on/near. At this point you can get any information from that Graphic you want. 4. Then you can pass this information to your second Activity via an Intent.For example, in the activity that has your map view (MapViewActivity in the the code below: map.setOnSingleTapListener(new OnSingleTapListener() {
@Override
public void onSingleTap(float x, float y) {
int[] ids = graphicsLayer.getGraphicIDs(x, y, 10, 1); // experiment with tolerance and num of results params here
if (ids != null && ids.length > 0)
{
Graphic foundGraphic = graphicsLayer.getGraphic(ids[0]);
if (foundGraphic != null) {
Intent intent = new Intent(MapViewActivity.this, GraphicActivity.class);
intent.putExtra("graphicInfo", String.valueOf(foundGraphic.getId()));
startActivity(intent);
}
}
}
});
Then in your second activity (called GraphicActivity in this example), you can get back the info from the Intent and show it somehow - just showing the ID in this example here:public class GraphicActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra("graphicInfo");
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText("GraphicID = " + message);
// Set the text view as the activity layout
setContentView(textView);
}
Hope this helps,