You're going to have to keep riding and trying different things to find out what works for you.
True, overexertion beyond what you've trained for can cause cramps. But I suspect the fact your cramps went away after drinking (presumably) electrolyte mix is an indication you were low on salt, water, or both.
Some concrete suggestions:
1. Drink a big glass of water before you start. Make sure you're drinking every 15 minutes or so on the road.
2. Find electrolytes that work for you. Concur with the suggestion to put them in a water bottle. FWIW, Heed works OK for me, Nuun used to but upsets my stomach now. Somewhat concentrated lemonade with a hefty pinch of salt in a bottle, drinking 3-4 swallows of that along with 3-4 swallows of water at every drink, usually does the trick for me.
3. If you run low on the road, see if a gas station or convenience store has V-8. It may taste like something your dad or grandmother would drink, but it's one of the best ways to get a concentrated dose of salt in you. Wash it down with plain water.