There is authority for localities to regulate the carry and discharge of firearms under certain conditions.
We have this:
§ 15.2-1209.1. Counties may regulate carrying of loaded firearms on public highways.
The governing body of any county is hereby empowered to adopt ordinances making it unlawful for any person to carry or have in his possession, for the purpose of hunting, while on any part of a public highway within such county a loaded firearm when such person is not authorized to hunt on the private property on both sides of the highway along which he is standing or walking; and to provide a penalty for violation of such ordinance not to exceed a fine of $100. The provisions of this section shall not apply to persons carrying loaded firearms in moving vehicles or for purposes other than hunting, or to persons acting at the time in defense of persons or property.
This:
29.1-526. Counties and cities may prohibit hunting or trapping near primary and secondary highways.
The governing body of any county or city may prohibit by ordinance the hunting, with a firearm, of any game bird or game animal while the hunting is on or within 100 yards of any primary or secondary highway in such county or city and may provide that any violation of the ordinance shall be a Class 3 misdemeanor. In addition, the governing body of any county or city may prohibit by ordinance the trapping of any game animal or furbearer within fifty feet of the shoulder of any primary or secondary highway in the county or city and may provide that any violation of the ordinance shall be a Class 3 misdemeanor. No such ordinance shall prohibit such trapping where the written permission of the landowner is obtained. It shall be the duty of the governing body enacting an ordinance under the provisions of this section to notify the Director by registered mail no later than May 1 of the year in which the ordinance is to take effect. If the governing body fails to make such notice, the ordinance shall be unenforceable.
For the purpose of this section, the terms "hunt" and "trap" shall not include the necessary crossing of highways for the bona fide purpose of going into or leaving a lawful hunting or trapping area.
This:
29.1-527. Counties, cities or towns may prohibit hunting near public schools and county, city, town or regional parks.
The governing body of any county, city or town may prohibit by ordinance, shooting or hunting with a firearm, or prohibit hunters from traversing an area while in possession of a loaded firearm, within 100 yards of any property line of a public school or a county, city, town or regional park. The governing body may, in such ordinance, provide that any violation thereof shall be a Class 4 misdemeanor. Nothing in this section shall give any county, city or town the authority to enforce such an ordinance on lands within a national or state park or forest, or wildlife management area.
And this:
18.2-286. Shooting in or across road or in street.
If any person discharges a firearm, crossbow or bow and arrow in or across any road, or within the right-of-way thereof, or in a street of any city or town, he shall, for each offense, be guilty of a Class 4 misdemeanor.
The provisions of this section shall not apply to firing ranges or shooting matches maintained, and supervised or approved, by law-enforcement officers and military personnel in performance of their lawful duties.