Speciation and the evolution of dispersal along environmental gradients