I came across the situation where I am supposed to determine the median of given list of coordinates and set the GoogleMap's Camera zooming level (So that all the coordinates to be displayed in single view on map load, user don't need to zoom the map).

I followed the below approach to determine the median of given co-ordinates.

```
Convert lat/lon to Cartesian coordinates for each location.
X = cos(lat) * cos(lon)
Y = cos(lat) * sin(lon)
Z = sin(lat)

Compute average x, y and z coordinates.
x = (x1 + x2 + ... + xn) / n
y = (y1 + y2 + ... + yn) / n
z = (z1 + z2 + ... + zn) / n

Convert average x, y, z coordinate to latitude and longitude.
Lon = atan2(y, x)
Hyp = sqrt(x * x + y * y)
Lat = atan2(z, hyp)

```

Ref : [Calculate the center point of multiple latitude/longitude coordinate pairs](https://stackoverflow.com/questions/6671183/calculate-the-center-point-of-multiple-latitude-longitude-coordinate-pairs)

Now I want to set the Google Map's camera zooming value so that all coordinates are covered in single view.

For example : 

If the list of coordinates are determined to be present in California as well as Florida, the Google Map should be loaded with displaying whole USA.

If the list of coordinates are determined to be present between California and Texas, only that portion of USA map should be displayed on setting zoom value of GoogleMap.

I am implementing this in Andriod application as well as iOS. 

Let me know how can we achieve this.