Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid GoogleMap v2 doesn't pan/zoom on swipe/pinch
    text
    copied!<p>I have a map v2 in a FrameLayout. If I don't animate it from code, it responds to touch/swipe/pinch events in the usual way. If I animate it after a onLocationChanged() call, the camera moves and zooms, but then the map stops responding to user input (or at least that is the feeling). You swipe but the map doesn't pan. You pinch but the map doesn't zoom. You tap... you get the idea.</p> <p>However I discovered by chance that something is actually happening, but it's not being shown for some reason. If, for example, I swipe, the map does not move but somehow records the swipe. If I touch the home button, which brings the system back to the home screen, and then bring the app again in foreground, I can see my map in the panned position, with the farthest zoom possible, without any markers I eventually added before. It seems that the swipe gesture was caught by a overlaid invisible map centered in lat=0, lng=0 and applied to that map, and it seems that now that map is the one being shown.</p> <p>Except that, using various breakpoints, it's clear that there aren't any other maps being created in my activity, let alone transparent and overlaid ones... my description serves only to let you understand what's going on, I'm not suggesting that there actually is another map above mine.</p> <p>Here are the relevant pieces of code, if you need more, just ask:</p> <p>my onCreate()</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.map_activity); } </code></pre> <p>my onStart() is:</p> <pre><code>@Override protected void onStart() { super.onStart(); // Create the LocationRequest object mLocationRequest = LocationRequest.create(); // Use high accuracy mLocationRequest.setPriority( LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the update interval to 5 seconds mLocationRequest.setInterval(UPDATE_INTERVAL); // Set the fastest update interval to 1 second mLocationRequest.setFastestInterval(FASTEST_INTERVAL); mLocationClient = new LocationClient(this, this, this); mLocationClient.connect(); } @Override public void onConnected(Bundle arg0) { mLocationClient.requestLocationUpdates(mLocationRequest, this); } </code></pre> <p>and my onLocationChanged() is</p> <pre><code>@Override public void onLocationChanged(Location loc) { if (mMap == null) { mapFragment = SupportMapFragment.newInstance(); FragmentTransaction fragmentTransaction = getSupportFragmentManager() .beginTransaction(); fragmentTransaction.add(R.id.mapcontainer, mapFragment); fragmentTransaction.commit(); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); mMap.getUiSettings().setAllGesturesEnabled(true); mMap.getUiSettings().setMyLocationButtonEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(true); mMap.getUiSettings().setCompassEnabled(true); mMap.setMyLocationEnabled(false); LatLng location = new LatLng(loc.getLatitude(), loc.getLongitude()); CameraPosition pos = new CameraPosition.Builder().target(location).zoom(12).build(); CameraUpdate cu = CameraUpdateFactory.newCameraPosition(pos); mMap.animateCamera(cu); if (mLocationClient.isConnected()) mLocationClient.removeLocationUpdates(this); mLocationClient.disconnect(); Log.e(getClass().getSimpleName(), "lat = " + location.latitude + " long = " + location.longitude); } } </code></pre> <p>Please note that I deferred map configuration until the first onLocationChanged() event because otherwise the map refused to animate to the requested location (see my other question for that: <a href="https://stackoverflow.com/questions/19683146/android-googlemap-v2-ignores-animate-move-calls">Android: GoogleMap v2 ignores animate/move calls</a> ).</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