Thanks for the answers, but I was looking for some native Map component to do the reset marker task, not the external button, to get back to the desired marker location. I got this working with the latest update in Map Api (to set setOnMyLocationButtonClickListener). Using the code below: -
mMap.setMyLocationEnabled(true); LatLng markerLoc=new LatLng(companyDetail.getLatitude(), companyDetail.getLongitude()); final CameraPosition cameraPosition = new CameraPosition.Builder() .target(markerLoc) // Sets the center of the map to Mountain View .zoom(13) // Sets the zoom .bearing(90) // Sets the orientation of the camera to east .tilt(30) // Sets the tilt of the camera to 30 degrees .build(); // mMap.addMarker(new MarkerOptions().position(new LatLng(companyDetail.getLatitude(), companyDetail.getLongitude())).title("Marker")); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); mMap.setOnMyLocationButtonClickListener(new OnMyLocationButtonClickListener() { @Override public boolean onMyLocationButtonClick() { mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); return true; } });
source share