bmh_cesium/public/widgets/showLayer/widget.js

35 lines
821 B
JavaScript
Raw Normal View History

2025-03-09 23:23:50 +00:00
//模块:
xjsdk.widget.bindClass(xjsdk.widget.BaseWidget.extend({
options: {
},
layerWork: null,
//初始化[仅执行1次]
create: function () {
if (this.config.layerId)
this.layerWork = this.viewer.xjsdk.getLayer(this.config.layerId, 'id');
else
this.layerWork = this.viewer.xjsdk.getLayer(this.config.name, 'name');
},
//打开激活
activate: function () {
if (this.layerWork == null) return;
this.lastVisible = this.layerWork._visible;
if (!this.lastVisible)
this.layerWork.setVisible(true);
this.layerWork.centerAt();
},
//关闭释放
disable: function () {
if (this.layerWork && !this.lastVisible)
this.layerWork.setVisible(false);
},
}));