Lin_Ye_Fang_Huo/public/widgets/navXZQH/widget.js

77 lines
2.0 KiB
JavaScript
Raw Normal View History

2023-07-18 09:04:15 +08:00
"use script"; //开发环境建议开启严格模式
(function (window, mars3d) {
2023-07-08 15:37:34 +08:00
//创建widget类需要继承BaseWidget
class MyWidget extends mars3d.widget.BaseWidget {
//弹窗配置
get view() {
return {
2023-07-18 09:04:15 +08:00
type: "window",
url: "view.html",
2023-07-08 15:37:34 +08:00
windowOptions: {
width: 220,
height: 440,
},
2023-07-18 09:04:15 +08:00
};
2023-07-08 15:37:34 +08:00
}
//初始化[仅执行1次]
create() {
//用于显示查询结果geojson的图层
this.geoJsonLayer = new mars3d.layer.GeoJsonLayer({
name: this.config.name,
2023-07-18 09:04:15 +08:00
pid: 99, //图层管理 中使用父节点id
2023-07-08 15:37:34 +08:00
symbol: {
2023-07-18 09:04:15 +08:00
type: "polygon",
2023-07-08 15:37:34 +08:00
styleOptions: {
fill: true,
2023-07-18 09:04:15 +08:00
color: "rgb(2,26,79)",
2023-07-08 15:37:34 +08:00
opacity: 0.4,
outline: true,
2023-07-18 09:04:15 +08:00
outlineColor: "#39E09B",
2023-07-08 15:37:34 +08:00
outlineWidth: 6,
outlineOpacity: 0.8,
arcType: Cesium.ArcType.GEODESIC,
clampToGround: true,
},
},
2023-07-18 09:04:15 +08:00
popup: "{name}",
});
2023-07-08 15:37:34 +08:00
}
//每个窗口创建完成后调用
winCreateOK(opt, result) {
2023-07-18 09:04:15 +08:00
this.viewWindow = result;
2023-07-08 15:37:34 +08:00
}
//打开激活
activate() {
2023-07-18 09:04:15 +08:00
this.geoJsonLayer.on(mars3d.EventType.load, this.geoJsonLayer_onLoadHandler, this);
this.map.addLayer(this.geoJsonLayer);
2023-07-08 15:37:34 +08:00
}
//关闭释放
disable() {
2023-07-18 09:04:15 +08:00
this.geoJsonLayer.clear();
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.geoJsonLayer.off(mars3d.EventType.load, this.geoJsonLayer_onLoadHandler, this);
this.map.removeLayer(this.geoJsonLayer);
2023-07-08 15:37:34 +08:00
2023-07-18 09:04:15 +08:00
this.viewWindow = null;
2023-07-08 15:37:34 +08:00
}
showRegionExtent(geojson) {
2023-07-18 09:04:15 +08:00
this.geoJsonLayer.clear();
this.geoJsonLayer.load({ data: geojson });
2023-07-08 15:37:34 +08:00
}
geoJsonLayer_onLoadHandler(event) {
// event.list
2023-07-18 09:04:15 +08:00
this.geoJsonLayer.flyTo();
2023-07-08 15:37:34 +08:00
}
goHome() {
2023-07-18 09:04:15 +08:00
this.geoJsonLayer.clear();
this.map.flyHome();
2023-07-08 15:37:34 +08:00
}
}
//注册到widget管理器中。
2023-07-18 09:04:15 +08:00
mars3d.widget.bindClass(MyWidget);
2023-07-08 15:37:34 +08:00
//每个widet之间都是直接引入到index.html中会存在彼此命名冲突所以闭包处理下。
2023-07-18 09:04:15 +08:00
})(window, mars3d);