Lin_Ye_Fang_Huo/public/widgets/measureChars/widget.js

79 lines
2.1 KiB
JavaScript
Raw Normal View History

2023-07-08 15:37:34 +08:00
'use script' //开发环境建议开启严格模式
;(function (window, mars3d) {
//创建widget类需要继承BaseWidget
class MyWidget extends mars3d.widget.BaseWidget {
//弹窗配置
get view() {
return {
type: 'window',
url: 'view.html',
windowOptions: {
width: 500,
height: 200,
},
}
}
//初始化[仅执行1次]
create() {}
//每个窗口创建完成后调用
winCreateOK(opt, result) {
this.viewWindow = result
}
//打开激活
activate() {
if (this.viewWindow) {
this.viewWindow.setEchartsData(this.config.data)
}
}
//内置方法,不重启方式刷新页面
update() {
if (this.viewWindow) {
this.viewWindow.setEchartsData(this.config.data)
}
}
//关闭释放
disable() {
this.viewWindow = null
this.hideTipMarker()
}
showTipMarker(point, z, inthtml) {
var _position_draw = Cesium.Cartesian3.fromDegrees(point.lng, point.lat, z)
if (!this.tipGraphic) {
this.tipGraphic = new mars3d.graphic.BillboardEntity({
name: '当前点',
position: _position_draw,
style: {
image: 'img/marker/mark3.png',
scale: 1,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 500000, 0.2),
},
}).addTo(this.map.graphicLayer)
this.tipGraphic._setPositionsToCallback()
}
this.tipGraphic._position_draw = _position_draw
this.tipGraphic
.bindPopup(inthtml, {
anchor: [0, -20], //左右、上下的偏移像素值。
})
.openPopup()
}
hideTipMarker() {
if (!this.tipGraphic) {
return
}
this.tipGraphic.remove(true)
this.tipGraphic = null
}
}
//注册到widget管理器中。
mars3d.widget.bindClass(MyWidget)
//每个widet之间都是直接引入到index.html中会存在彼此命名冲突所以闭包处理下。
})(window, mars3d)