views:

43

answers:

1

Hi all. I'm doing some maths calculations in android map activity and I need to find a position of a GeoPoint which user has clicked on the map. I understand that I need to use onTouch event handler. This is how it looks like at the moment:

@Override
public boolean onTouch(View v, MotionEvent event) {

    int action = event.getAction();

    if(action == MotionEvent.ACTION_DOWN)
    {
        GeoPoint pGoal = mapView.getProjection().fromPixels(
                (int) event.getX(),
                (int) event.getY());

        DisplayInfoMessage("The screen has been touched!" + event.getX() + " AND " + event.getY() + "Latitude: "+ pGoal.getLatitudeE6());   // only for displaying test popup

    }
    super.onTouchEvent(event);

    return true;        

}  

It doesn't do what I want though. Any help or hint at least greatly appreciated!

+1  A: 

Actually this already is the answer:

@Override
    public boolean onTouch(View v, MotionEvent event) {

        int action = event.getAction();

        if(action == MotionEvent.ACTION_DOWN)
        {
            GeoPoint pGoal = mapView.getProjection().fromPixels(
                    (int) event.getX(),
                    (int) event.getY());

            DisplayInfoMessage("The screen has been touched!" + event.getX() + " AND " + event.getY() + "Latitude: "+ pGoal.getLatitudeE6());   // only for displaying test popup

        }
        super.onTouchEvent(event);

        return true;        

    }  
Pavel