Ecological speciation in dynamic landscapes