I've had roving cramps through every muscle in my legs, all my life.
Best solution I've found -- besides appropriate saddle height/angle, and appropriate cleat placement -- has been stretching and massage post-ride, and physical therapy off the bike to strengthen and stabilize the hips, knees and ankles.
I also add electrolytes to at least one bottle every ride, and take magnesium lactate supplement before and after. Supposedly the lactate form of magnesium and potassium work better, although they can make some folks gassy -- seems to depend on whether we're lactose intolerant. I was a little gassy the first couple of times I took it but seemed to adapt quickly. I also take digestive enzymes daily so maybe that helps.
For leg massage the best thing I've found has been a heavy marble rolling pin. It's a decorative but seldom used kitchen doodad I've had for years, but it's seen more use on my legs than on dough. The weight of the marble does all the work, and it's cooling too.
I also use a foam roller and percussion massager elsewhere, especially neck, shoulders and back. Helps on the lower back and hips. I seem to have fewer problems with leg spasms now.