hmm, never did thisâ€¦ but i would start this way:

-given that your environment is top-down and your camera is unrotated ( x is left&right on the viewport, z is top and bottom)
-get the the lowest and highest position.x value among the objects
-get the the lowest and highest position.z value among the objects
-the middle between those positions is your x and z value where your camera should be centered at
-then calculate the distance to ground (zoom) of your camera:
â€“based on the fov your distance would be equal to (zCenter-zMax) of the objects if your fov is 90
â€“use z because fov is the vertical camera angle
â€“if your fov is other than 90 you have to compensate for that, if its only 45 you would have to use 2*zCenter-zMax as camera height
â€“be sure to clamp the minimum camera height at a reasonable level

//the formulas after you found the min and max values:
float xCenter = (xMax-xMin)/2F;
float zCenter = (zMax-zMin)/2F;
float height = 90F/Camera.fieldOfView * zMax-zCenter * 1.2F
//*1.2 to zoom out a bit farther then needed, the objects would be on the very edge if not
Vector3 unSmoothCameraPosition = new Vector3(xCenter, height, zCenter);
cameraTransform.position = Vector3.Lerp(cameraTransform.position,unSmoothCameraPosition,Time.deltaTime*gm.cameraSmoothFactor);

if you are not top down however, forget everything i said
if your camera is rotated use the a rotated localposition of an object with the same rotation as the camera or sin() cos() to calculate the referential to the camera

A minor correction here, if someone else is interested to implement it on their project.
You will have to change the way xCenter and zCenter are calculated, because right now itâ€™s not the real center, you should do something like this:

Thanks but no, actually I participated to the Global game jam this weekend, we made this game: http://globalgamejam.org/2016/games/idle-idol
You can try it, you will see the camera moving like what you said

On Subaeria we use a far more complicated camera system :-/