I've been having the same problem the last couple of weeks. What I tried was
1. Better balance to my hydration (not over or under hydrating)
2. Increased Magnesium and Calcium intake
3. Adjusted (ever so slightly) my cleat position for more toe-in.
Rode 100+ miles this weekend and didn't have any leg cramps. Hopefully the problem is solved.