The extended population associated with W40
  W40 is a heavily obscured bipolar HII region projected in the direction of
the Aquila Rift and ionized by hot stars in a central, partly embedded cluster.
The study of the cluster and its surroundings has been greatly hampered thus
far by the strong extinction in the region. We use the Gaia eDR3 catalog to
establish astrometric membership criteria based on the population of the W40
central cluster, reassess the distance of the region, and identify in this way
new members, both inside and outside the cluster. We obtain visible
spectroscopy in the red spectral region to classify both known and new members,
complemented with Gaia and Spitzer photometry to assess the evolutionary status
of the stellar population. We derive a high-confidence geometric distance to
the W40 region of 502 pc $\pm$ 4 pc and confirm the presence of a comoving
extended population of stars at the same distance, spreading over the whole
projected area of the HII region and beyond. Spectral classifications are
presented for 21 members of the W40 region, 10 of them belonging to the central
cluster. One of the newly identified B stars in the extended population is
clearly interacting with the shell surrounding the HII region, giving rise to a
small arc-shaped nebula that traces a bow shock. The infrared excess properties
suggest that the extended population is significantly older ($\sim 3$ Myr) than
the W40 central cluster ($< 1$ Myr). The area currently occupied by the W40 HII
region and its surroundings has a history of star formation extending at least
several million years in the past, of which the formation of the W40 central
cluster and the subsequent HII region is one of the latest episodes. The newly
determined distance suggests that W40 is behind, and physically detached from,
a pervasive large dust layer which is some 60 pc foreground to it as determined
by previous studies.
