Hello I have made a map overlay class and have overridden the onTouchEvent method that looks like this :
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView)
{
//TO-DO here we will capture when the users
//has pointed a point to go..
if(event.getAction() != MotionEvent.ACTION_MOVE){
GeoPoint p = mapView.getProjection().fromPixels(
(int) event.getX(),
(int) event.getY());
Geocoder geoCoder = new Geocoder(
getBaseContext(), Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocation(
p.getLatitudeE6() / 1E6,
p.getLongitudeE6() / 1E6, 1);
String add = "";
if (addresses.size() > 0)
{
for (int i=0; i<addresses.get(0).getMaxAddressLineIndex();
i++)
add += addresses.get(0).getAddressLine(i) + "\n";
}
Log.e("##################",
"screen touched: lat:"+(p.getLatitudeE6()/ 1E6)+"long:"+(p.getLongitudeE6()/ 1E6));
showMap((p.getLatitudeE6()/ 1E6),(p.getLongitudeE6()/ 1E6));
Toast.makeText(getBaseContext(), add, Toast.LENGTH_SHORT).show();
}
catch (IOException e) {
e.printStackTrace();
}
return true;
}else
return false;
}
the problem is that the map is drawn every time I do a gesture on the map, I would like to do this only when I click on a spot on the map and not when I drag the map, is this approach correct? how to implement this? regards maxsap