Let $(X,d,\mu)$ be a metric space with doubling measure and $L$ be a nonnegative self-adjoint operator on $L^2(X)$ whose heat kernel satisfies Gaussian upper bound.Given H\ormander type spectral multipliers $m_i,1\leq i\leq N,$ with uniform estimates, we prove an optimal $\sqrt{\log(1+N)}$ bound in $L^p$ for the maximal function $\sup_{1\leq i\leq N}|m_i(L)f|$ by making use of Doob transform and some techniques as in Grafakos-Honz\'ik-Seeger \cite{GHS2006} to use the ${\rm exp}(L^2)$ estimate by Chang-Wilson-Wolff \cite{CWW1985}. Based on this, we establish sufficient conditions on the bounded Borel function $m$ such that the maximal function %$ M_{m,L}$ $M_{m,L}f(x) = \sup_{t>0} |m(tL)f(x)|$ is bounded on $L^p(X)$. The applications include Scattering operators, Schr\odinger operators with inverse square potential, Dirichlet Laplacian with Dirichlet boundary, Bessel operators and Laplace-Beltrami operators.