2

I have set zoom and camera around a marker on googlemap using following code

LatLng coordinate = new LatLng(lat,lon);
CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 11.0f);
map.animateCamera(yourLocation);

Its working but when i try to zoom in or out using gesture or control it goes back to same zoom level which is set initially.

What additional settings are required ?

thanks

vishal dharankar
  • 7,536
  • 7
  • 57
  • 93
  • You say it zooms when you do but than gets back to its inital state? So the gestures are detected? – Recomer Aug 05 '16 at 08:24
  • @Recomer exactly , i want to know how to override this behaviour – vishal dharankar Aug 05 '16 at 08:25
  • Maybe you can checkout this link. Look like the same problem and solved. http://stackoverflow.com/questions/37979555/google-map-undesirably-resets-camera-zoom-out – Recomer Aug 05 '16 at 08:27
  • @Recomer no that scenario is different than mine, i set zoom just once in the beginning. – vishal dharankar Aug 05 '16 at 08:31
  • What is it you want actually? I may not get the question right. – Recomer Aug 05 '16 at 08:33
  • @Recomer i just want map to zoom in the beginning and as user changes zoom level let it do. But right now when user zooms in or out map goes back or resets to the original zoom – vishal dharankar Aug 05 '16 at 08:35
  • You can use `googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(getTaskLocationLatLng(latlng, zoomLevel(float type)));` to set an initial zoom. And then maybe you can set a break point to default zoomOut() method and check when it gets Called and maybe you can set up a good logic there to decide if it should get called or not. – Recomer Aug 05 '16 at 08:42
  • @Recomer I have set maximum zoom and minimum zoom already do you mean this ? Also I didn't get you last point of setting break point to default zoom out – vishal dharankar Aug 05 '16 at 08:49
  • @Recomer is there a listener where I can come to know if user is trying to zoom in or out ? So that I can set zoom levels – vishal dharankar Aug 05 '16 at 08:50
  • Okay, this is the solution. You first implement the listener, than call that listener onCameraChange(), get the zoom level from cameraPosition, set it as your new zoom level manually as you did initially. Checkout : http://stackoverflow.com/questions/13973886/zoom-level-listener-in-google-maps-v2-in-android – Recomer Aug 05 '16 at 08:53
  • @Recomer thanks checking – vishal dharankar Aug 05 '16 at 08:54

0 Answers0