Probably a combination of overexertion and dehydration. Get lots of fluids before and during the ride. In my case, I've found that at rest stops sitting down is not a good idea. Like cyclist200 said, take it easy, even if it means slowing down. Also, during the rest stops it might help to do some calf stretches.