Added self-adaptive z-index value for layer