I have the following code to show my actual location on Google Maps:
public class LocationProjectActivity extends MapActivity implements OnTouchListener {
private MapController mapController;
private MapView mapView;
private LocationManager locationManager;
private MyOverlays itemizedoverlay;
private MyLocationOverlay myLocationOverlay;
private GeoPoint MyPoint;
public static int longitude;
public static int latitude;
private GeoPoint destinationPoint;
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
mapView.computeScroll();
mapController = mapView.getController();
mapController.setZoom(13);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, new GeoUpdateHandler());
myLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
mapView.getController().animateTo(myLocationOverlay.getMyLocation());
}
});
}
@Override
public boolean onTouch(View v, MotionEvent event) {
System.out.println("SCREEN WAS CLICKED");
return true;
}
What I want to do is catch when I touch the screen, but the method is never called. I already searched and found this: OnTouch in map
I tried everything and the only code that works was this:
mapView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// Your code and remember to return true!
return (true);
}
});
The problem is that if I use this code, my MapView loses the natural fling and zoom that it already has, so how can I have everything in my MapView?
Thank you.