const mapMenuTools = {
|
colorAll: {
|
point: SmartEarth.Cesium.Color.fromCssColorString("#ff0000"),
|
polyline: SmartEarth.Cesium.Color.fromCssColorString("#ffff0050"),
|
polygon: SmartEarth.Cesium.Color.fromCssColorString("#ffff0050"),
|
},
|
analysisFlood: null,
|
viewThrough: null,
|
skyline: null,
|
particle: null,
|
smoke: null,
|
effect: null,
|
Fireworks: null,
|
PointFly: null,
|
PointBillboard: null,
|
Init(res) {
|
switch (res.type) {
|
case "cl":
|
this.setMapMenuCl(res);
|
break;
|
case "bh":
|
this.setMapMenuBH(res);
|
break;
|
case "my":
|
this.setMapMenuMY(res);
|
break;
|
case "fx":
|
this.setMapMenuFX(res);
|
break;
|
case "tx":
|
this.setMapMenuTX(res);
|
break;
|
}
|
},
|
setClearTX() {
|
if (this.particle) {
|
this.particle.remove();
|
this.particle = null;
|
}
|
if (this.smoke) {
|
this.smoke.remove();
|
this.smoke = null;
|
}
|
if (this.effect) {
|
this.effect.remove();
|
this.effect = null;
|
}
|
},
|
setMapMenuTX(res) {
|
switch (res.id) {
|
case "hy":
|
if (this.particle) {
|
this.setClearTX();
|
return;
|
}
|
var that = this;
|
var handler = new Cesium.ScreenSpaceEventHandler(
|
window.Viewer.scene.canvas
|
);
|
handler.setInputAction((event) => {
|
let cartesian = window.Viewer.camera.pickEllipsoid(event.position);
|
let cartographic =
|
SmartEarth.Cesium.Cartographic.fromCartesian(cartesian);
|
|
if (cartesian) {
|
let lng = parseFloat(
|
Cesium.Math.toDegrees(cartographic.longitude)
|
).toFixed(6); // 经度
|
let lat = parseFloat(
|
Cesium.Math.toDegrees(cartographic.latitude)
|
).toFixed(6); // 纬度
|
var alt =
|
window.Viewer.camera.positionCartographic.height.toFixed(0);
|
console.log(lng);
|
that.setCreateFireAnalysis(lng, lat, alt);
|
}
|
handler.removeInputAction(
|
SmartEarth.Cesium.ScreenSpaceEventType.LEFT_CLICK
|
);
|
}, SmartEarth.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
break;
|
case "yw":
|
if (this.smoke) {
|
this.setClearTX();
|
return;
|
}
|
var that = this;
|
var handler = new Cesium.ScreenSpaceEventHandler(
|
window.Viewer.scene.canvas
|
);
|
handler.setInputAction((event) => {
|
let cartesian = window.Viewer.camera.pickEllipsoid(event.position);
|
let cartographic =
|
SmartEarth.Cesium.Cartographic.fromCartesian(cartesian);
|
|
if (cartesian) {
|
let lng = parseFloat(
|
Cesium.Math.toDegrees(cartographic.longitude)
|
).toFixed(6); // 经度
|
let lat = parseFloat(
|
Cesium.Math.toDegrees(cartographic.latitude)
|
).toFixed(6); // 纬度
|
var alt =
|
window.Viewer.camera.positionCartographic.height.toFixed(0);
|
console.log(lng);
|
that.setCreateSmoke(lng, lat, alt);
|
}
|
handler.removeInputAction(
|
SmartEarth.Cesium.ScreenSpaceEventType.LEFT_CLICK
|
);
|
}, SmartEarth.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
break;
|
case "pq":
|
if (this.effect) {
|
this.setClearTX();
|
return;
|
}
|
var that = this;
|
var handler = new Cesium.ScreenSpaceEventHandler(
|
window.Viewer.scene.canvas
|
);
|
handler.setInputAction((event) => {
|
let cartesian = window.Viewer.camera.pickEllipsoid(event.position);
|
let cartographic =
|
SmartEarth.Cesium.Cartographic.fromCartesian(cartesian);
|
|
if (cartesian) {
|
let lng = parseFloat(
|
Cesium.Math.toDegrees(cartographic.longitude)
|
).toFixed(6); // 经度
|
let lat = parseFloat(
|
Cesium.Math.toDegrees(cartographic.latitude)
|
).toFixed(6); // 纬度
|
var alt =
|
window.Viewer.camera.positionCartographic.height.toFixed(0);
|
that.setCreateEffect(lng, lat, alt);
|
}
|
handler.removeInputAction(
|
SmartEarth.Cesium.ScreenSpaceEventType.LEFT_CLICK
|
);
|
}, SmartEarth.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
break;
|
case "txqc":
|
this.setClearTX();
|
break;
|
}
|
},
|
setCreateEffect(lon, lat, alt) {
|
let position = {
|
x: lon,
|
y: lat,
|
z: 0,
|
};
|
this.effect = earthCtrl.factory.createParticleEffect(
|
"fountain",
|
position,
|
{
|
translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //平移
|
},
|
function (data) {}
|
);
|
},
|
setCreateSmoke(lon, lat, alt) {
|
//添加烟雾
|
this.smoke = earthCtrl.factory.createSmoke({
|
lon: lon,
|
lat: lat,
|
alt: 0,
|
});
|
},
|
|
setCreateFireAnalysis(lon, lat, alt) {
|
this.particle = earthCtrl.factory.createParticleEffect(
|
"flame",
|
{
|
x: lon,
|
y: lat,
|
z: 0,
|
},
|
{
|
translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //平移
|
},
|
(data) => {}
|
);
|
},
|
setClearAnalysisFlood() {
|
this.analysisFlood && this.analysisFlood.endWater();
|
this.analysisFlood = null;
|
},
|
setClearViewThrough() {
|
this.viewThrough.deleteAll();
|
this.viewThrough = null;
|
},
|
setMapMenuFX(res) {
|
switch (res.id) {
|
case "ymfx":
|
if (this.analysisFlood) {
|
setClearAnalysisFlood();
|
return;
|
}
|
const method = {
|
pointSelect: true,
|
spood: parseFloat(50),
|
GroupID: 0,
|
url: SmartEarthRootUrl + "Workers/image/waterNormals.jpg",
|
};
|
this.analysisFlood = earthCtrl.analysis.createSubmergence(
|
method,
|
(value) => {}
|
);
|
break;
|
case "tsfx":
|
if (this.viewThrough) {
|
this.setClearViewThrough();
|
}
|
this.viewThrough = earthCtrl.analysis.createViewThrough();
|
break;
|
case "tjxfx":
|
if (this.skyline) {
|
this.kyline.removeFromMap();
|
this.skyline = null;
|
return;
|
}
|
// 创建天际线分析
|
this.skyline = earthCtrl.analysis.createSkyline({
|
color: SmartEarth.Cesium.Color.fromCssColorString("#ff0"),
|
width: 3,
|
});
|
break;
|
case "fxqc":
|
if (this.analysisFlood) {
|
setClearAnalysisFlood();
|
}
|
if (this.viewThrough) {
|
setClearViewThrough();
|
}
|
if (this.skyline) {
|
this.skyline.removeFromMap();
|
this.skyline = null;
|
}
|
break;
|
}
|
},
|
setMapDdMay(res) {
|
this.PointFly = earthCtrl.camera.rotateCamera({
|
lon: res.lon,
|
lat: res.lat,
|
distance: 1000,
|
pitch: -30,
|
});
|
},
|
setMapMenuMY(res) {
|
switch (res.id) {
|
case "ddmy":
|
var that = this;
|
if (that.PointFly) {
|
earthCtrl.factory.SimpleGraphic.clear();
|
that.PointFly.removeFromMap();
|
that.PointFly = null;
|
that.PointBillboard = null;
|
return;
|
}
|
that.PointBillboard = window.earthCtrl.factory.createSimpleGraphic(
|
"billboard",
|
{},
|
function (entity) {
|
const position = entity.position.getValue();
|
const coordinate = window.earthCtrl.core.toDegrees(position);
|
that.setMapDdMay(position);
|
}
|
);
|
|
break;
|
|
case "xlmy":
|
earthCtrl.camera.executeFlycesium((data) => {
|
data.showPoint = false;
|
data.showLine = true;
|
data.mode = 1;
|
// 弹窗数据
|
window.PathAnimationData = {
|
flyData: data,
|
};
|
window.PathAnimationData.winIndex = layer.open({
|
type: 2,
|
title: "路径动画",
|
shade: false,
|
area: ["352px", "690px"],
|
offset: "r",
|
skin: "other-class",
|
content: SmartEarthRootUrl + "Workers/path/Path.html",
|
end: function () {
|
PathAnimationData.fly && PathAnimationData.fly.exit();
|
},
|
});
|
});
|
break;
|
}
|
},
|
setMapMenuBH(res) {
|
switch (res.id) {
|
case "label":
|
earthCtrl.factory.createSimpleGraphic(
|
"label",
|
{},
|
function (entity) {}
|
);
|
break;
|
case "billboard":
|
earthCtrl.factory.createSimpleGraphic(
|
"billboard",
|
{},
|
function (entity) {}
|
);
|
break;
|
case "polyline":
|
earthCtrl.factory.createSimpleGraphic(
|
"polyline",
|
{
|
showSize: true,
|
},
|
function (entity) {}
|
);
|
break;
|
case "rectangle":
|
earthCtrl.factory.createSimpleGraphic(
|
"rectangle",
|
{
|
showSize: true,
|
},
|
function (entity) {}
|
);
|
break;
|
case "polygon":
|
earthCtrl.factory.createSimpleGraphic(
|
"polygon",
|
{
|
showSize: true,
|
},
|
function (entity) {}
|
);
|
break;
|
case "bhqc":
|
earthCtrl.factory.SimpleGraphic.clear();
|
break;
|
}
|
},
|
setMapMenuCl(res) {
|
switch (res.id) {
|
case "jl":
|
earthCtrl.measure.lineDistance(this.colorAll, (e) => {
|
console.log(e);
|
});
|
break;
|
case "bmjl":
|
earthCtrl.measure.clampLineDistance(this.colorAll, (e) => {
|
console.log(e);
|
});
|
break;
|
case "mj":
|
earthCtrl.measure.planeArea(this.colorAll, (e) => {
|
console.log(e);
|
});
|
break;
|
case "bmmj":
|
earthCtrl.measure.surfaceArea(
|
{
|
...this.colorAll,
|
tin: true, // 是否显示tin三角网
|
onlyTerrain: false, // 是否只测量精细地形
|
},
|
(e) => {
|
console.log(e);
|
}
|
);
|
break;
|
case "czgd":
|
earthCtrl.measure.height(this.colorAll, (e) => {
|
console.log(e);
|
});
|
break;
|
case "clqc":
|
earthCtrl.measure.clearResult();
|
break;
|
}
|
},
|
};
|
export default mapMenuTools;
|