The legend will now close if all layers are removed from the map