  Let $M$ be a compact orientable surface equipped with a volume form $\omega$,
$P$ be either $\mathbb{R}$ or $S^1$, $f:M\to P$ be a $C^{\infty}$ Morse map,
and $H$ be the Hamiltonian vector field of $f$ with respect to $\omega$. Let
also $\mathcal{Z}_{\omega}(f) \subset C^{\infty}(M,\mathbb{R})$ be set of all
functions taking constant values along orbits of $H$, and
$\mathcal{S}_{\mathrm{id}}(f,\omega)$ be the identity path component of the
group of diffeomorphisms of $M$ mutually preserving $\omega$ and $f$.
  We construct a canonical map $\varphi: \mathcal{Z}_{\omega}(f) \to
\mathcal{S}_{\mathrm{id}}(f,\omega)$ being a homeomorphism whenever $f$ has at
least one saddle point, and an infinite cyclic covering otherwise. In
particular, we obtain that $\mathcal{S}_{\mathrm{id}}(f,\omega)$ is either
contractible or homotopy equivalent to the circle.
  Similar results hold in fact for a larger class of maps $M\to P$ whose
singularities are equivalent to homogeneous polynomials without multiple
factors.
