Seaside resort towns are among those with the highest rates of death from heroin and morphine, figures show.