fix a bug when the layer isn't added to any map.