The ruling is a blow to Republicans who hoped to use the maps to shore up their narrow House majority ahead of the midterms.