I also will periodically fill a cramp coming which I recognize I put that pedal at 6 o'clock stand straight up push my heel down and stretch that calve as much as I can it helps me.
If its my thigh I will put it at 12 o'clock so its stretched as much as possible on the bike if I can I'll take my thumb and stretch out the muscle like a massage method this helps me.
But drink plenty and try to prevent it first but sometimes it happens.