Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: OnTouchListener not responding at MapView
    text
    copied!<p>I have the following code to show my actual location on Google Maps:</p> <pre><code>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; } </code></pre> <p>What I want to do is catch when I touch the screen, but the method is never called. I already searched and found this: <a href="https://stackoverflow.com/questions/3664554/ontouch-in-mapview-only-fires-the-first-time">OnTouch in map</a></p> <p>I tried everything and the only code that works was this:</p> <pre><code>mapView.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { // Your code and remember to return true! return (true); } }); </code></pre> <p>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?</p> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload