In my application I'm trying to get the center coordinates of map when user scroll around the map.
I want to get the co-ordinates and set it on the text view.
Here is my code for that:
public boolean onTouchEvent(MotionEvent event) {
int action=event.getAction();
projection=mapView.getProjection();
int X = (int)event.getX();
int Y = (int)event.getY();
if(action==MotionEvent.ACTION_MOVE)
{
metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
GeoPoint G = projection.fromPixels(metrics.heightPixels/2, metrics.widthPixels/2);
//GeoPoint p= mapView.getMapCenter();
int lati=p.getLatitudeE6();
Log.i("Lat : ",""+lati);
Toast.makeText(this,""+lati,Toast.LENGTH_LONG);
int longi=p.getLongitudeE6();
Log.i("Lon : ",""+longi);
Toast.makeText(this,""+longi,Toast.LENGTH_LONG);
lat.setText(""+lati);
lon.setText(""+longi);
}
return true;
}