I suffered through upper and lower leg cramps along with foot cramps for a couple years. The good news is that I seem to have "outgrown" them but I'm not sure exactly why. I even asked my doctor for advice a couple years ago and he suggested the quinine-but to get it from tonic water. So, I would drink a bottle an hour before I rode but it tasted nasty plus it tended to upset my stomach while riding. I then asked a pharmicist about getting quinine and she suggested the "leg cramps". I rarely take them now but still find them useful at night sometimes.
I wondered if mine were related to medication I was taking. That reallly has not changed but the cramps have greatly subsided. I've eliminated caffeine and most of the alcohol from my diet so that might have been of help. I've also added potassium by increasing my intake of bananas. Maybe it's related to the fact I've ridden 20,000 miles and my legs are in better shape.
I wish I could help but not sure I have good advice other than increased potassium and calcium and less alcohol and caffeine. Plus, maybe it will tone down as the legs tone up.......