Hi all,
Now i have a MapView instance in MapActivity and I want to capture a
touch event. So when people touch on map, i want to display longitude
and latitude.
But when i touch on this, my program doesn't work.
Here is my code and please show me where is my error.
Thanks in advance,
**********************************************************************************************************
public class Test_map extends MapActivity {
private MapView mapView;
private Projection mProjection;
private GeoPoint test_g;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.map_view);
mProjection = mapView.getProjection();
mapView.setSatellite(true);
mapView.setStreetView(true);
mapView.setEnabled(true);
mapView.setFocusable(true);
mapView.setFocusableInTouchMode(true);
mapView.requestFocus();
..........................................
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
test_g = mProjection.fromPixels((int)event.getX(), (int)event.getY
());
Toast.makeText(this, test_g.getLatitudeE6() +"\n"+
test_g.getLongitudeE6() , Toast.LENGTH_SHORT);
return true;
}
@Override
protected boolean isRouteDisplayed()
{
//IMPORTANT: This method must return true if your Activity
//is displaying driving directions. Otherwise return false.
return false;
}
}
**********************************************************************************************************
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---