public static function getBoundsOfBounds($boundaries, $margin = 0.0)
    {
        $minLat = 1000;
        $maxLat = -1000;
        $minLng = 1000;
        $maxLng = -1000;
        foreach ($boundaries as $bounds) {
            if (!($bounds instanceof LatLngBounds)) {
                throw new InvalidParamException('"$boundaries" must be an array of "' . self::className() . '" objects');
            }
            $minLat = min($minLat, $bounds->getSouthWest()->getLat());
            $minLng = min($minLng, $bounds->getSouthWest()->getLng());
            $maxLat = max($maxLat, $bounds->getNorthEast()->getLat());
            $maxLng = max($maxLng, $bounds->getNorthEast()->getLng());
        }

        if ($margin > 0) {
            $minLat = $minLat - $margin * ($maxLat - $minLat);
            $minLng = $minLng - $margin * ($maxLng - $minLng);
            $maxLat = $maxLat + $margin * ($maxLat - $minLat);
            $maxLng = $maxLng + $margin * ($maxLng - $minLng);
        }

        return new self(
            [
                'southWest' => new LatLng(['lat' => $minLat, 'lng' => $minLng]),
                'northEast' => new LatLng(['lat' => $maxLat, 'lng' => $maxLng])]
        );
    }