Using Gaia to derive distances to embedded objects