Most cramps are due to overuse, especially when it is not as hot out and hydration is less of an issue. So, if you've recently ramped up the duration and/or intensity of your rides, then you need to dial it back some. Also, be aware that if you're experiencing cramps due to overuse, you will be more likely to cramp for a period of time until your muscles have time to fully recover. Could be weeks, for a bad case of cramps.
Hydration, the second leading cause, is more likely when it is hot out. As the previous posters have noted, you need more electrolytes and fluids before, during and after your ride. There are various products out there (Gatorade, Nuun tablets, and the like).
Then, more rarely, there are medical conditions that can lead to cramping - you need to see a Dr.
Also, some medications can make cramping more likely - see Dr. or pharmacist.
It's hard to determine the cause of your cramps from the information you've given, therefore it is difficult to give specific advice.
--------------