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