In the last years, the automotive industry has shown interest in the addition of computing and communication devices to cars, thanks to technological advances in these fields, in order to meet the increasing demand of "connected" applications and services. Although vehicular ad hoc networks (VANETs) have not been fully developed yet, they could be used in a near future as a means to provide a number of interesting applications and services that need the exchange of data among vehicles and other data sources. In this paper, we propose a spatial crowdsourcing schema for the opportunistic collection of information within an interest area in a city or region (e.g., measures about the environment, such as the concentration of certain gases in the atmosphere, or information such as the availability of parking spaces in an area), using vehicular ad hoc communications. We present a method that exploits mobile agent technology to accomplish the distributed collection and querying of data among vehicles in such a scenario. Our proposal is supported by an extensive set of realistic simulations that prove the feasibility of the approach.