Stretches: The most common muscle involved and in which it is commonly seen is the calf muscle. One has to do periodic stretches of the calf and also of the thigh (Quadriceps & Hamstrings) during training.
Hydration: This is the single most important factor causing cramps. Keep yourself well hydrated before and during the marathon. Drink a lot of fluids before and during the marathon. Dehydration causes cramps. Before the marathon drink only water and during you can drink sports drinks
Rest: before the marathon one should take adequate rest and sleep
Diet: one should reduce intake of too much proteins and fats during the lead up to the day of the marathon. Caffeinated drinks and alcohol should be completely avoided these cause muscle dehydration.
During marathon one should eat bananas which gives a lot of potassium which reduces the risk of cramps
Taper of training intensity as you approach the day
Wear comfortable shoes which do not cause strain on the ankle which will also cause cramps.