Android : How to handle click event on zoom buttons of default google map in android?

on Sunday, September 14, 2014



I have implemented google map in android activity with zoom gestures and zoom control enabled. There is handler implemntation also that continously change camera focus of map at fixed zoom level. As shown in following code -


public void initializeMap(){
mGoogleMap.setMyLocationEnabled(true);
mPolyLineOptions = new PolylineOptions().width(6).color(Color.RED);
mGoogleMap.setTrafficEnabled(true);
mGoogleMap.getUiSettings().setMyLocationButtonEnabled(true);
mGoogleMap.getUiSettings().setRotateGesturesEnabled(true);
mGoogleMap.getUiSettings().setCompassEnabled(true);
mGoogleMap.getUiSettings().setZoomGesturesEnabled(true);
mGoogleMap.getUiSettings().setZoomControlsEnabled(true);
mGoogleMap.getUiSettings().setIndoorLevelPickerEnabled(true);
handler=new Handler();
handler.postDelayed(updateMarker, MARKER_UPDATE_INTERVAL);
}



Runnable updateMarker = new Runnable() {
@Override
public void run() {

animateCameraTo();
handler.postDelayed(this, MARKER_UPDATE_INTERVAL);
}
};

private void animateCameraTo() {

CameraPosition cameraPosition = new CameraPosition.Builder().target(latlang).zoom(30).build();
mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}


Now animateCameraTo method will keep on changing focus as latlng is getting change with gps.


Now when I do press zoom in zoom out button i.e default in google map the handler goes on changing camera focus and unable to handle zoom controls.


How can i stop handler from refocusing camera when zoom in and zoom is pressed in google map android. Zoom Controls


0 comments:

Post a Comment