So I guess I’m going to go against the norm here... I think it’s ok to let strangers pet your dog... but only on your terms. I don’t let strangers pet my dogs over their heads or touch their ears. I flat out tell them no if they are overly gushy (my word for ppl who want to smoosh and cuddle everything) or excited. I tell them how they can pet my dogs, first an open palm sniff then under the muzzle or on either side. I watch my dogs, if either are showing signs of discomfort, I give a quick “thank you”, “heel” and move on. I find most people are happy to and respond well when I direct them. I feel doing what I do allows my dogs to not really care if people are around, approaching us, or walking closely around us.
The only other difference between your scenario and my standard “meeting strangers” scenario is I don’t and won’t ever go to a dog park. My pit likes to meet strangers the most, my GSD wants to sniff and get on with the walk.