Effects of environmental heterogeneity on the dynamics of marine metapopulations