Fixes #91995 by correctly calculating the layer's id for removal.
Merge pull request #279 from luisromangz/91995-FixIPTLayersLegendRemoval

Fixes #91995 by correctly calculating the layer's id for removal.