Light (pseudo-)scalar fields are promising candidates to be the dark matter in the Universe. Under certain initial conditions in the early Universe and/or with certain types of self-interactions, they can form compact dark-matter objects such as axion stars or Q-balls. Direct encounters with such objects can be searched for by using a global network of atomic magnetometers. It is shown that for a range of masses and radii not ruled out by existing observations, the terrestrial encounter rate with axion stars or Q-balls can be sufficiently high (at least once per year) for a detection. Furthermore, it is shown that a global network of atomic magnetometers is sufficiently sensitive to pseudoscalar couplings to atomic spins so that a transit through an axion star or Q-ball could be detected over a broad range of unexplored parameter space.