I was thinking that instead of having full blown gyms that spawn in the world, there could just be Gym leaders that spawn in the world. For example, lets say you were walking through the extreme hills and you happened to stumble upon Brock, or if you were walking on the beach you might see Misty. They would spawn in just like trainers just a lot more rare.
If you beat the gym leader then it would drop the badge and a TM of the correct type.
The Gym leaders would obviously have to be very rare and fairly powerful, but it would still be a cool way to implement the gym badges.
SPG's disapproval goes here ------->