/* eslint-disable quotes */
|
/* eslint-disable comma-dangle */
|
/* eslint-disable semi */
|
/* eslint-disable space-before-function-paren */
|
/* eslint-disable no-unused-vars */
|
import $store from "../index";
|
import axios from "axios";
|
|
import urlParameter from "./mobiles/urlParameter";
|
|
import VectorLayer from "ol/layer/Vector";
|
import VectorSource from "ol/source/Vector";
|
|
import { LineString } from "ol/geom";
|
import Feature from "ol/Feature.js";
|
import Point from "ol/geom/Point.js";
|
import { Icon, Style, Fill, Text, Stroke } from "ol/style.js";
|
|
import openlayerData from "./openlayerData";
|
import mobilePosition from "./mobilePosition";
|
|
window.popupsDom = null; // mobileDivForms的实体类
|
window.flytoPosition = null; // mobileDivForms的实体类
|
window.ellipsoid = null;
|
window.cartographic = null;
|
|
window.useHeight = null;
|
window.vecLayer = null;
|
window.vecLayer = null;
|
window.pointLayer = null;
|
window.drawALineLayerMany = null; // 活动线
|
window.drawALineLayerManycolor = null; // 活动线颜色
|
window.drawALineLayerManyStyle = null; // 活动线样式
|
window.drawALineLayerManypolyline = null; // 活动线样式
|
window.drawAPointLayerMany = null; // 活动点
|
window.drawAPointLayerManyposition = null; // 活动点位置
|
window.drawAPointLayerManyLabels = null; // 活动点
|
// window.tilesetLayer = null;
|
// window.wallLayer = null;
|
window.areaLayer = null;
|
window.tileset = null;
|
window.drawALineLayer = null; // 导航路径图层
|
|
window.drawALineLayerdrawALine = null; // 导航路径画线方法
|
window.drawALineLayerIcon = null; // 导航路径图层图标
|
window.billboarddaohang = null; // 导航点
|
window.positiondaohang = null; // 导航点位置
|
window.polylinedaohang = null; // 导航线
|
window.polylinematerialdaohang = null; // 导航线属性
|
|
window.select = {
|
// 绿色图层控制显示
|
overlay: undefined,
|
color: undefined,
|
};
|
|
window.tancuanPosition = null;
|
|
// window.newLayer = null;
|
// window.usetowpointfive = null;
|
|
let pathUrl = [
|
{
|
key: 1,
|
url: "https://fkxt.jxstnu.edu.cn/changjing/arcgis155/rest/services/hjzlw/NAServer/%E8%B7%AF%E5%BE%84/solve",
|
},
|
{
|
key: 2,
|
url: "https://fkxt.jxstnu.edu.cn/changjing/arcgis155/rest/services/fllw/NAServer/%E8%B7%AF%E5%BE%84/solve",
|
},
|
];
|
|
const mobile = {
|
state: {
|
...urlParameter.state, // url参数
|
// mviewer: null, // 地图实体类
|
mBigPopup: false, // 全屏弹窗
|
popupOurOpenData: [], // 全屏弹窗中下拉菜单数据
|
popupTableName: [], // 全屏弹窗标签页数据
|
mBigPopupAfter: false, /// /全屏弹窗之前的弹窗
|
ips: "", // 获取的ip
|
iconHide: true, // 右侧伸缩状态
|
// DC: '',//DC全局保存
|
MobileWindowsHide: true, // 改变点击窗口的显示状态
|
MobileWindowChangeData: false, // 改变点击窗口的数据
|
// popupsDom: '', // mobileDivForms的实体类
|
query: {}, // 传输数据
|
openmobileGoTo: false, // 测试
|
ccDataState: false, // 测试
|
openmobilePanorama: false, // 实景显影
|
MobileWindowsHideFixed: true, // 改变点击窗口的显示状态--固定窗口
|
MobileWindowChangeDataFixed: false, // 改变点击窗口的数据--固定窗口
|
// 在每次飞行弹窗中 加入自己的点
|
// pointLayer: null,
|
pointLayerData: {
|
flag: false,
|
label: "选择点",
|
img: "/changjing/img/leftnav/way.png",
|
normal: "/changjing/img/leftnav/way.png",
|
checked: "/changjing/img/leftnav/way-checked.png",
|
layer: "pointLayer",
|
},
|
dimension: "2.5D", // 维度
|
dimensionData: {
|
// 维度镜头数据
|
heading: 0,
|
pitch: -90,
|
roll: 0,
|
},
|
zoomRange: [100, 1000], // 缩放程度
|
frislayertHeight: 160, // 默认弹窗高度
|
perspectiveControl: "", // 视角控制:高度、角度 ()=>{}
|
perspectiveControls: "", // 视角控制:高度、角度 ()=>{}
|
|
// tilesetLayer: null, // 3d模型
|
// tileset: null, // 3d模型
|
// tilesetLayer: null, // 2.5d模型
|
// usetowpointfive: null,
|
// wallLayer: null, // 瀑布流
|
// areaLayer: null, // 2.5d事件--绿色图层
|
// select: {
|
// // 绿色图层控制显示
|
// overlay: undefined,
|
// color: undefined
|
// },
|
|
// vecLayer: null, // 3D底图
|
// cvaLayer: null, // 3D底图
|
|
audioData: null, // 语音
|
audioState: false, // 语音状态
|
|
navigationStartLngLat: "", // 导航起点
|
navigationEndLngLat: "", // 导航终点
|
// drawALineLayer: null, // 导航路径图层
|
// drawALineLayerIcon: null, // 导航路径图层图标
|
isOpenDrawALine: false, // 是否开启路径
|
endPosition: "", // 传送终点经纬度--
|
isendPosition: false, // 传送终点经纬度--感应数据
|
routerS: [], // 所有路径
|
choiceRouterS: 0, // 当前选择路径
|
|
showActivity: false, // 是否显示活动弹窗
|
showActivityData: {}, // 活动内容
|
|
// drawALineLayerMany: null, // 活动路线图层
|
// drawAPointLayerMany: null, // 活动点图层
|
isOpenDrawALineMany: null, // 是否开启活动
|
seeRight: true, // 右侧控制栏显影
|
pinchFlag: false,
|
},
|
mutations: {
|
...urlParameter.mutations, // url参数
|
// MSET_VIEWER (state, viewer) {
|
// global.viewer = viewer
|
// },
|
SET_PINCHFLAG(state, pinchFlag) {
|
state.pinchFlag = pinchFlag;
|
},
|
MSET_BIGPOPUP(state, viewer) {
|
state.mBigPopup = viewer;
|
$store.dispatch("closeMobileWindowsDom"); // 关闭弹窗
|
},
|
MSET_BIGPOPUPAFTER(state, viewer) {
|
state.mBigPopupAfter = viewer;
|
$store.dispatch("closeMobileWindowsDom"); // 关闭弹窗
|
},
|
MSET_POPUPOUROPENDATA(state, viewer) {
|
state.popupOurOpenData = viewer;
|
},
|
MSET_ICONHIDE(state, viewer) {
|
state.iconHide = viewer;
|
},
|
MSET_POPUPTABLENAME(state, viewer) {
|
state.popupTableName = viewer;
|
},
|
MSET_MOBILEWINDOWSHIDE(state, viewer) {
|
// 随地图移动窗口
|
state.MobileWindowChangeData = !state.MobileWindowChangeData;
|
state.MobileWindowsHide = viewer;
|
},
|
MSETCC_SETCC(state, viewer) {
|
state.ccDataState = !state.ccDataState; // 专门测试
|
state.query = viewer;
|
},
|
// MSET_POPUPDOM(state, viewer) {
|
// window.popupsDom = viewer
|
// },
|
MSET_QUERY(state, viewer) {
|
state.query = viewer;
|
},
|
MSET_OPENMOBILEGOTO(state, viewer) {
|
state.openmobileGoTo = viewer;
|
},
|
MSET_OPENMOBILEPANORAMA(state, viewer) {
|
state.openmobilePanorama = viewer;
|
},
|
MSET_MOBILEWINDOWSHIDEFIXED(state, viewer) {
|
// 固定窗口
|
state.MobileWindowChangeDataFixed = !state.MobileWindowChangeDataFixed;
|
state.MobileWindowsHideFixed = viewer;
|
},
|
// // 开关飞入点图标
|
// MSET_OPENPOINTEL(state, val) {
|
// if (val) {
|
// state.pointLayerData.img = state.pointLayerData.checked
|
// state[state.pointLayerData.layer].show = true
|
// } else {
|
// state.pointLayerData.img = state.pointLayerData.normal
|
// state[state.pointLayerData.layer].show = false
|
// }
|
// },
|
// 送入移动端缩放范围
|
set_zoomRange(state, data) {
|
state.zoomRange = data;
|
},
|
// 送入默认弹窗高度
|
set_frislayertHeight(state, data) {
|
state.frislayertHeight = data;
|
},
|
SET_DIMENSION(state, dimension) {
|
state.dimension = dimension;
|
},
|
SET_DIMENSIONDATA(state, dimensionData) {
|
state.dimensionData = dimensionData;
|
},
|
// 切换2D和2.5D
|
MSET_DIMENSION(state, data) {
|
// 关闭弹窗
|
// 3d,2.5d转换事件
|
state.dimension = data;
|
if (data == "3D") {
|
// 改数据为3d数据
|
state.dimensionData = {
|
// 维度镜头数据
|
heading: 0,
|
pitch: -45,
|
roll: 0,
|
};
|
// 加载底图
|
if (!window.vecLayer) {
|
// window.vecLayer = global.viewer.imageryLayers.addImageryProvider(
|
// new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
|
// url: 'https://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=789e558be762ff832392a0393fd8a4f1',
|
// subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
|
// format: 'image/jpeg',
|
// show: true,
|
// maximumLevel: 18
|
// })
|
// )
|
// window.cvaLayer = global.viewer.imageryLayers.addImageryProvider(
|
// new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
|
// url: 'https://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=789e558be762ff832392a0393fd8a4f1',
|
// subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
|
// format: 'image/jpeg',
|
// show: true,
|
// maximumLevel: 18
|
// })
|
// )
|
}
|
// console.log(1321)
|
window.wallLayer.show = false; // 关闭瀑布 以及2.5d图形贴片
|
global.viewer.imageryLayers.remove(window.newLayer);
|
window.newLayer = null;
|
// state.silhouetteBlue.selected = []
|
// window.tilesetLayer.changesilhouetteBlue(); //清空silhouetteBlue.selected = [];
|
// console.log(window.tileset)
|
window.tilesetLayer.show = true; // 显示3d图形
|
// global.viewer.flyTo(window.tileset);
|
window.areaLayer.show = false; // 绿布
|
// 3D视角不限制
|
global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 80;
|
// 最大
|
global.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 4000000;
|
// 设置相机缩小时的速率
|
global.viewer.scene.screenSpaceCameraController._minimumZoomRate = 10000;
|
// 设置相机放大时的速率
|
global.viewer.scene.screenSpaceCameraController._maximumZoomRate = 5906376272000;
|
// 视角平移
|
global.viewer.scene.screenSpaceCameraController.enableRotate = true;
|
// 视角缩放
|
global.viewer.scene.screenSpaceCameraController.enableZoom = true;
|
// 视角旋转
|
global.viewer.scene.screenSpaceCameraController.enableTilt = true;
|
} else if (data == "2.5D") {
|
state.dimensionData = {
|
// 维度镜头数据
|
heading: 0,
|
pitch: -90,
|
roll: 0,
|
// heading: global.DC.Namespace.Cesium.Math.toRadians(-9),
|
// pitch: global.DC.Namespace.Cesium.Math.toRadians(-34.54),
|
// roll: 0,
|
};
|
// 取消3D底图
|
// global.viewer.imageryLayers.remove(window.vecLayer);
|
// window.vecLayer = null;
|
// global.viewer.imageryLayers.remove(window.cvaLayer);
|
// window.cvaLayer = null;
|
// 加载底图
|
// window.vecLayer = global.viewer.imageryLayers.addImageryProvider(
|
// new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
|
// url: 'https://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=789e558be762ff832392a0393fd8a4f1',
|
// subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
|
// format: 'image/jpeg',
|
// show: true,
|
// maximumLevel: 18
|
// })
|
// )
|
|
// window.cvaLayer = global.viewer.imageryLayers.addImageryProvider(
|
// new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
|
// url: 'https://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=789e558be762ff832392a0393fd8a4f1',
|
// subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
|
// format: 'image/jpeg',
|
// show: true,
|
// maximumLevel: 18
|
// })
|
// )
|
|
window.tilesetLayer.show = false; // 隐藏3d图形
|
window.newLayer = window.usetowpointfive(); // 添加2.5d图形贴片
|
window.wallLayer.show = false; // 打开瀑布
|
window.areaLayer.show = true; // 绿布
|
if (state.zoomRange[3]) {
|
global.viewer.imageryLayers.addImageryProvider(
|
new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
|
url: "/fz/{z}/{x}/{y}.png",
|
fileExtension: "png",
|
// minimumLevel: 19
|
})
|
);
|
// global.viewer.imageryLayers.addImageryProvider(
|
// new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
|
// url: "https://dev.jxpskj.com:8023/arcgis/rest/services/FZ25DMap/MapServer/WMTS",
|
// layer: "fzsw2019",
|
// style: "default",
|
// tileMatrixSetID: "default028mm",
|
// format: "image/jpgpng",
|
// tilingScheme: new global.DC.Namespace.Cesium.GeographicTilingScheme(),
|
// maximumLevel: 19,
|
// tileMatrixLabels: [
|
// "0",
|
// "1",
|
// "2",
|
// "3",
|
// "4",
|
// "5",
|
// "6",
|
// "7",
|
// "8",
|
// "9",
|
// "10",
|
// "11",
|
// "12",
|
// "13",
|
// "14",
|
// "15",
|
// "16",
|
// "17",
|
// "18",
|
// "19",
|
// ],
|
// })
|
// );
|
// 2.5D视角限制
|
// global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 50
|
// // 最大
|
// global.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 9999999999
|
} else {
|
}
|
// 2.5D视角限制
|
global.viewer.scene.screenSpaceCameraController.minimumZoomDistance =
|
state.zoomRange[0];
|
// 最大
|
global.viewer.scene.screenSpaceCameraController.maximumZoomDistance =
|
state.zoomRange[1];
|
// 设置相机缩小时的速率
|
global.viewer.scene.screenSpaceCameraController._minimumZoomRate = 2000;
|
// 设置相机放大时的速率
|
global.viewer.scene.screenSpaceCameraController._maximumZoomRate = 5906376272000;
|
// 视角平移
|
global.viewer.scene.screenSpaceCameraController.enableRotate = true;
|
// 视角缩放
|
global.viewer.scene.screenSpaceCameraController.enableZoom = true;
|
// 视角旋转
|
global.viewer.scene.screenSpaceCameraController.enableTilt = false;
|
}
|
},
|
// 绿布
|
MSET_areaLayer(state, data) {
|
window.areaLayer = data;
|
},
|
// 切换控制
|
MSET_PERSPECTIVECONTROL(state, data) {
|
state.perspectiveControl = data;
|
state.perspectiveControls = !state.perspectiveControls;
|
},
|
// MSET_MODEOLS(state, data) {
|
// window.tilesetLayer = data.tilesetLayer
|
// window.newLayer = data.newLayer
|
// window.wallLayer = data.wallLayer
|
// window.tileset = data.tileset
|
// window.usetowpointfive = data.usetowpointfive
|
// },
|
// 直接移动
|
cameraSetView(state, data) {
|
global.viewer.camera.setView({
|
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
|
// fromDegrees()方法,将经纬度和高程转换为世界坐标
|
// eslint-disable-next-line new-cap
|
destination: new global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
|
// 114.0351,
|
// 27.6314,
|
// 200.0
|
data[0],
|
data[1],
|
data[2] || 300
|
),
|
orientation: {
|
heading: global.DC.Namespace.Cesium.Math.toRadians(
|
state.dimensionData.heading
|
),
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(
|
state.dimensionData.pitch
|
),
|
// heading: data.heading,
|
// pitch: data.pitch,
|
roll: state.dimensionData.roll,
|
},
|
});
|
},
|
// 删除路线
|
removePolyline(state) {
|
if (window.drawALineLayer) {
|
openlayerData.state.openlayers.map2D.removeLayer(window.drawALineLayer);
|
window.drawALineLayer = null;
|
state.isOpenDrawALine = false;
|
}
|
},
|
removerPolyLineIcon(state) {
|
if (window.drawALineLayerIcon) {
|
window.drawALineLayerIcon.getSource().clear();
|
window.drawALineLayerIcon = null;
|
}
|
},
|
removePolylineMany(state) {
|
if (window.drawALineLayerMany) {
|
openlayerData.state.openlayers.map2D.removeLayer(
|
window.drawALineLayerMany
|
);
|
window.drawALineLayerMany = null;
|
state.isOpenDrawALineMany = false;
|
}
|
if (window.drawAPointLayerMany) {
|
openlayerData.state.openlayers.map2D.removeLayer(
|
window.drawAPointLayerMany
|
);
|
window.drawAPointLayerMany = null;
|
state.isOpenDrawALineMany = false;
|
}
|
},
|
// 显影线路或者点
|
showLineOrPoint(state, val) {
|
window[val.layer].visible = val.flag;
|
},
|
// 传送终点数据
|
set_endPosition(state, data) {
|
state.isendPosition = !state.isendPosition;
|
state.endPosition = data;
|
},
|
// 传送当前选择的路径
|
set_choiceRouterS(state, data) {
|
state.choiceRouterS = data;
|
},
|
// 活动窗口是否显示
|
set_showActivity(state, data) {
|
state.showActivity = data;
|
if (data.state) {
|
state.showActivityData = data.value;
|
state.showActivity = data.state;
|
} else {
|
state.showActivityData = {};
|
state.showActivity = data.state;
|
}
|
},
|
mset_changeSelect(state, data) {
|
window.select.overlay = data[0];
|
window.select.color = data[1];
|
},
|
SET_SeeAndNotSee(state, data) {
|
state.seeRight = data;
|
},
|
},
|
actions: {
|
...urlParameter.actions, // url参数
|
MSET_CREADE({ state, commit, dispatch }) {
|
window.pointLayer = new global.DC.VectorLayer("pointLayer"); // 创建图标实体类
|
global.viewer.addLayer(window.pointLayer); // 添加到地图
|
},
|
setMobileWindows({ state, commit, dispatch }, data) {
|
// 打开随地图移动窗口
|
let clas, Flys;
|
// const nowHeight = Math.ceil(
|
// global.viewer.camera.positionCartographic.height
|
// )
|
// 传递响应数据
|
commit("MSET_QUERY", data);
|
// console.log(data);
|
// 配置移动和弹窗的偏移 flys是飞行的偏移 clas是弹窗的偏移
|
if (state.dimension == "3D") {
|
Flys = [
|
+data.lntLat[0] + 0.01197,
|
// +data.lntLat[1] - 0.0001,
|
+data.lntLat[1] - 0.0027,
|
330,
|
];
|
clas = [
|
data.from == "PopupOurOnce" ? +data.lntLat[0] : +data.lntLat[0],
|
// data.from == 'PopupOurOnce' ? +data.lntLat[1] - 0.00108 : +data.lntLat[1],
|
data.from == "PopupOurOnce"
|
? +data.lntLat[1] - 0.00108
|
: +data.lntLat[1] - 0.00048,
|
data.from == "PopupOurOnce" ? 0 : 30.648862227,
|
];
|
} else if (state.dimension == "2.5D") {
|
Flys = [
|
+data.lntLat[0] + 0.01197,
|
+data.lntLat[1] + 0.00048,
|
// +data.lntLat[1] - 0.0022,
|
// nowHeight,
|
state.frislayertHeight,
|
];
|
// console.log(nowHeight);
|
clas = [
|
data.from == "PopupOurOnce" ? +data.lntLat[0] : +data.lntLat[0],
|
data.from == "PopupOurOnce" ? +data.lntLat[1] : +data.lntLat[1],
|
// data.from == 'PopupOurOnce' ? +data.lntLat[1] - 0.00108 : +data.lntLat[1] - 0.00048,
|
// data.from == 'PopupOurOnce' ? 0 : 90.648862227
|
data.from == "PopupOurOnce" ? 0 : 0,
|
];
|
}
|
window.tancuanPosition = data.position;
|
// useJWD开启状态 window.tancuanPosition就是根据经纬度来计算出来的 如果有原有的 data.position 把值变为false
|
if (data.useJWD) {
|
window.ellipsoid = global.viewer.scene.globe.ellipsoid;
|
window.cartographic =
|
global.DC.Namespace.Cesium.Cartographic.fromDegrees(
|
// data.lntLat[0],
|
// data.lntLat[1] - 0.00048,//数值增大是下
|
// "90.648862227"
|
// clnt, clat, calt
|
...clas
|
);
|
window.tancuanPosition = window.ellipsoid.cartographicToCartesian(
|
window.cartographic
|
);
|
}
|
|
// 定制化窗体
|
// eslint-disable-next-line new-cap
|
window.popupsDom = new global.DC.mobileDivForms(global.viewer, {
|
domId: "mobilePopup",
|
title: data.query.name || "成教楼 ",
|
className: "mobilePopup",
|
content: document.getElementById("mobile-map_content_content"),
|
position: [window.tancuanPosition],
|
});
|
// commit("MSET_MOBILEWINDOWSHIDE", false)//显示弹窗
|
// dispatch("CHANGETOC3", { // 转换坐标
|
// lnt: data.lntLat[0],
|
// lat: data.lntLat[1]
|
// }).then(res => {
|
// console.log(res)
|
|
// 基于高度基础设置
|
// h:1530
|
// lnt: + 0.01187 x轴 大是向左
|
// Lat: - 0.0108 y轴 减是上
|
// h:4000
|
// lnt: + 0.01187 x轴
|
// Lat: - 0.0308 y轴
|
// h:330
|
// lnt: + 0.01197 x轴
|
// Lat: - 0.0021 y轴
|
// console.log(data.query.from, 78)
|
// let Flys = [
|
// data.query.from == "地图点击" ? +data.lntLat[0] + 0.01197 : +data.lntLat[0] + 0.01197,
|
// data.query.from == "地图点击" ? +data.lntLat[1] - 0.0021 : +data.lntLat[1] - 0.0021,
|
// data.query.from == "地图点击" ? 330 : 330,
|
// ]
|
|
window.flytoPosition = new global.DC.Position( // 转坐标
|
// +data.lntLat[0] + 0.01197,
|
// +data.lntLat[1] - 0.0021,
|
// 330,
|
...Flys,
|
0,
|
state.dimensionData.pitch
|
);
|
if (!state.MobileWindowsHide) {
|
// 关闭弹窗
|
commit("MSET_MOBILEWINDOWSHIDE", true);
|
}
|
if (
|
window.select.overlay != undefined &&
|
data.query.fromTo != "mapClick"
|
) {
|
// 关闭绿色边框
|
window.select.overlay.setStyle({
|
material: window.select.color,
|
outline: false,
|
});
|
commit("mset_changeSelect", [undefined, undefined]);
|
}
|
// console.log(state.dimension);
|
if (state.dimension != "2.5D") {
|
// if (true) {
|
// if (true) {
|
dispatch("mapFlyTo", {
|
// 飞入
|
lntLat: [
|
window.flytoPosition.lng,
|
window.flytoPosition.lat,
|
window.flytoPosition.alt,
|
],
|
heading: window.flytoPosition.heading,
|
pitch: window.flytoPosition.pitch,
|
roll: window.flytoPosition.roll,
|
});
|
} else {
|
dispatch("mapFlyTo", {
|
// 飞入
|
lntLat: [
|
window.flytoPosition.lng,
|
+window.flytoPosition.lat - 0.0003,
|
window.flytoPosition.alt,
|
],
|
heading: window.flytoPosition.heading,
|
pitch: window.flytoPosition.pitch,
|
roll: window.flytoPosition.roll,
|
});
|
// global.viewer.camera.setView({
|
// // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
|
// // fromDegrees()方法,将经纬度和高程转换为世界坐标
|
// destination: new global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
|
// // 114.0351,
|
// // 27.6314,
|
// // 200.0
|
// Position.lng - 0.012,
|
// Position.lat - 0.0003,
|
// Position.alt || 15000.0
|
// ),
|
// orientation: {
|
// heading: global.DC.Namespace.Cesium.Math.toRadians(
|
// Position.heading
|
// ),
|
// pitch: global.DC.Namespace.Cesium.Math.toRadians(Position.pitch),
|
// // heading: data.heading,
|
// // pitch: data.pitch,
|
// roll: Position.roll,
|
// },
|
// });
|
// commit("MSET_MOBILEWINDOWSHIDE", false); // 显示弹窗
|
}
|
// })
|
// commit('MSET_POPUPDOM', popupsDom)
|
},
|
closeMobileWindowsDom({ state, commit, dispatch }) {
|
commit("CLOSE_NOWPOSITION"); // 中断定位获取
|
if (!state.MobileWindowsHide && window.popupsDom) {
|
window.popupsDom.closeOur();
|
commit("MSET_MOBILEWINDOWSHIDE", true);
|
if (state.audioData) {
|
dispatch("MSET_GETAUDIOBEGIN", "notOpen");
|
}
|
} // cancel
|
},
|
// CHANGETOC3({
|
// state,
|
// commit
|
// }, data) {
|
// // //转换经纬度坐标 成世界坐标cartesian3
|
// var ellipsoid = global.viewer.scene.globe.ellipsoid
|
// var cartographic = global.DC.Namespace.Cesium.Cartographic.fromDegrees(
|
// data.lnt,
|
// data.lat - 0.00006,
|
// data.alt || '90.648862227'
|
// )
|
// var position = ellipsoid.cartographicToCartesian(cartographic)
|
// return position
|
// },
|
SET_OPENWIDOWFIXED({ state, commit }, data) {
|
// 传递响应数据
|
commit("MSET_QUERY", data);
|
// 显示窗口
|
commit("MSET_MOBILEWINDOWSHIDEFIXED", false);
|
// 移动地图位置
|
global.viewer.zoomToPosition(
|
new global.DC.Position(
|
data.lntLat[0],
|
data.lntLat[1] - 0.012,
|
1530,
|
0,
|
-45
|
)
|
);
|
},
|
CLOSE_WIDOWFIXED({ state, commit }) {
|
// 隐藏窗口
|
if (!state.MobileWindowsHideFixed) {
|
commit("MSET_MOBILEWINDOWSHIDEFIXED", true);
|
}
|
},
|
// 加入当时的选点
|
JOIN_POINT({ state, commit }, data) {},
|
// flyTo
|
mapFlyTo({ state, commit, dispatch }, data) {
|
global.viewer.camera.flyTo({
|
destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
|
data.lntLat[0] - 0.012,
|
data.lntLat[1],
|
data.lntLat[2] || 15000.0
|
),
|
// destination: data.res,
|
orientation: {
|
heading: global.DC.Namespace.Cesium.Math.toRadians(data.heading),
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(data.pitch),
|
// heading: data.heading,
|
// pitch: data.pitch,
|
roll: data.roll,
|
},
|
duration: 1, // 定位的时间间隔
|
complete: () => {
|
// 完成后的回调
|
if (data.fn) {
|
// 自定义回调
|
setTimeout(() => {
|
data.fn();
|
}, 200);
|
}
|
if (!data.noOpen) {
|
setTimeout(() => {
|
// dispatch("MSET_POINTDATA", data.lntLat);//传入标记点
|
!state.MobileWindowsHide ||
|
commit("MSET_MOBILEWINDOWSHIDE", false); // 显示弹窗
|
}, 100);
|
}
|
},
|
});
|
// 官网flyto使用方法
|
// 1. Fly to a position with a top-down view
|
// viewer.camera.flyTo({
|
// destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0)
|
// });
|
|
// // 2. Fly to a Rectangle with a top-down view
|
// viewer.camera.flyTo({
|
// destination : Cesium.Rectangle.fromDegrees(west, south, east, north)
|
// });
|
|
// // 3. Fly to a position with an orientation using unit vectors.
|
// viewer.camera.flyTo({
|
// destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
|
// orientation : {
|
// direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734),
|
// up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339)
|
// }
|
// });
|
|
// // 4. Fly to a position with an orientation using heading, pitch and roll.
|
// viewer.camera.flyTo({
|
// destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
|
// orientation : {
|
// heading : Cesium.Math.toRadians(175.0),
|
// pitch : Cesium.Math.toRadians(-35.0),
|
// roll : 0.0
|
// }
|
// });
|
},
|
// 飞入点加入位置
|
// MSET_POINTDATA({
|
// state,
|
// commit,
|
// dispatch
|
// }, data) {
|
// // 加入坐标
|
// const positions = new global.DC.Position(
|
// data[0] - 0.0119,
|
// data[1] + 0.0111,
|
// 0
|
// )
|
// const billboard = new global.DC.Billboard(
|
// positions,
|
// '/changjing/img/leftnav/map-panorama.png'
|
// )
|
// billboard.size = [16, 16]
|
// // 订阅事件3
|
// billboard.on(global.DC.MouseEventType.CLICK, (e) => {
|
// // 定制化窗体
|
// const query = {
|
// name: '选择点'
|
// }
|
// const intLat = [e.wgs84Position.lng, e.wgs84Position.lat]
|
// const d = {
|
// position: null,
|
// lntLat: intLat,
|
// query: {
|
// ...(query || {}),
|
// introduce: null,
|
// address: intLat
|
// },
|
// useJWD: true // 仅使用经纬度
|
// }
|
// dispatch('setMobileWindows', d)
|
// })
|
// window.pointLayer.addOverlay(billboard) // 实景
|
// // commit("MSET_OPENPOINTEL", true);
|
// },
|
MSET_LOCKPERSPECTIVEL({ state, commit, dispatch }, val) {
|
// 锁定
|
global.viewer.camera.lookAtTransform(
|
global.DC.Namespace.Cesium.Matrix4.IDENTITY
|
);
|
// console.log(global.DC.Namespace.Cesium.Matrix4.IDENTITY)
|
},
|
MSET_DIMENSIONS({ state, commit, dispatch }, val) {
|
// 关闭弹窗
|
dispatch("closeMobileWindowsDom");
|
// 3d,2.5d转换事件
|
commit("MSET_DIMENSION", val);
|
// 控制高度
|
window.useHeight = Math.ceil(
|
global.viewer.camera.positionCartographic.height
|
);
|
global.viewer.camera.setView({
|
destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
|
global.viewer.camera.positionCartographic.longitude,
|
global.viewer.camera.positionCartographic.latitude,
|
window.useHeight
|
),
|
orientation: {
|
heading: global.DC.Namespace.Cesium.Math.toRadians(
|
state.dimensionData.heading
|
), // 方向
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(
|
state.dimensionData.pitch
|
), // 倾斜角度
|
roll: state.dimensionData.roll,
|
},
|
});
|
},
|
MSET_GOTOCC({ state, commit, dispatch }, val) {
|
// 测试移动位置
|
// commit("MSET_DIMENSION", val);
|
// 控制高度
|
// const height = Math.ceil(global.viewer.camera.positionCartographic.height);
|
global.viewer.camera.setView({
|
destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
|
global.viewer.camera.positionCartographic.longitude,
|
global.viewer.camera.positionCartographic.latitude,
|
val.height
|
),
|
orientation: {
|
heading: global.DC.Namespace.Cesium.Math.toRadians(val.heading), // 方向
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(val.pitch), // 倾斜角度
|
roll: val.roll,
|
},
|
});
|
},
|
// 文字转语音控制↓
|
MSET_GETAUDIO({ state, commit, dispatch }, val) {
|
state.audioData = new window.SpeechSynthesisUtterance();
|
state.audioData.text = val;
|
state.audioData.onstart = function (e) {
|
state.audioState = true;
|
};
|
state.audioData.onend = function (event) {
|
state.audioState = false;
|
};
|
},
|
MSET_GETAUDIOBEGIN({ state, commit, dispatch }, val) {
|
if (state.audioState) {
|
window.speechSynthesis.cancel();
|
state.audioState = false;
|
} else {
|
if (val != "notOpen") {
|
window.speechSynthesis.speak(state.audioData);
|
}
|
}
|
},
|
// 文字转语音控制↑
|
// 导航系统↓
|
MSET_GOTOWHERE({ state, commit, dispatch }, val) {
|
state.routerS = []; // 清空存着的路径
|
// 单条步行
|
// 本地图使用的是WGS84坐标,而高德使用的是火星坐标GCJ02,所以需要转换参数过去
|
// 返回值需要转换为WGS84坐标
|
state.navigationStartLngLat = [
|
Number(val.start[0]).toFixed(6),
|
Number(val.start[1]).toFixed(6),
|
]; // 导航起点
|
state.navigationEndLngLat = [
|
Number(val.end[0]).toFixed(6),
|
Number(val.end[1]).toFixed(6),
|
]; // 导航终点
|
|
let curPath = pathUrl.find(
|
(item) => item.key == mobilePosition.state.currentCampus
|
);
|
|
const data = {
|
stops: {
|
features: [
|
{
|
geometry: {
|
x: state.navigationStartLngLat[0],
|
y: state.navigationStartLngLat[1],
|
},
|
},
|
{
|
geometry: {
|
x: state.navigationEndLngLat[0],
|
y: state.navigationEndLngLat[1],
|
},
|
},
|
],
|
},
|
returnDirections: false,
|
returnRoutes: true,
|
f: "json",
|
};
|
axios
|
.get(curPath.url, {
|
params: {
|
...data,
|
},
|
})
|
.then((res) => {
|
// 回调
|
|
let Str = res.data.routes.features[0].geometry.paths[0].map(
|
(item) => {
|
return [item[0], item[1]];
|
}
|
);
|
|
if (val.fn) {
|
const dataS = {
|
Str: Str,
|
};
|
// console.log(Str);
|
state.routerS.push(dataS);
|
return val.fn(dataS);
|
} else {
|
dispatch("MSET_DRAWALINELAYER", Str); // 绘画线路
|
}
|
});
|
},
|
// 导航系统↑
|
// 绘画线路
|
MSET_DRAWALINELAYER({ state, commit, dispatch }, value) {
|
// 检查是否存在路线
|
commit("removePolyline");
|
commit("removePolylineMany");
|
|
window.drawALineLayer = new VectorLayer({
|
// 图标图层
|
zIndex: 32,
|
source: new VectorSource(),
|
});
|
openlayerData.state.openlayers.map2D.addLayer(window.drawALineLayer);
|
|
const line = new LineString(value);
|
|
const style = new Style({
|
stroke: new Stroke({
|
color: "red", // 线段颜色
|
width: 4, // 线段宽度
|
}),
|
});
|
|
const feature = new Feature({
|
geometry: line, // 将线段对象作为特征的几何属性
|
});
|
|
feature.setStyle(style);
|
|
window.drawALineLayer.getSource().addFeature(feature);
|
|
state.isOpenDrawALine = true;
|
|
// commit("cameraSetView", state.navigationStartLngLat); //移动
|
},
|
// 绘画线路活动多条
|
MSET_DRAWALINELAYERMANY({ state, commit, dispatch }, value) {
|
// 检查是否存在路线
|
commit("removePolylineMany");
|
commit("removePolyline");
|
commit("removerPolyLineIcon");
|
const Strs = value[0];
|
|
window.drawALineLayerMany = new VectorLayer({
|
// 图标图层
|
zIndex: 32,
|
source: new VectorSource(),
|
});
|
openlayerData.state.openlayers.map2D.addLayer(window.drawALineLayerMany);
|
|
window.drawAPointLayerMany = new VectorLayer({
|
// 图标图层
|
zIndex: 32,
|
source: new VectorSource(),
|
});
|
openlayerData.state.openlayers.map2D.addLayer(window.drawAPointLayerMany);
|
|
// 多条线
|
for (const k in Strs) {
|
const lineCoordinates = Strs[k].value
|
.split(";")
|
.map((item) => item.split(","));
|
|
const line = new LineString(lineCoordinates);
|
|
const style = new Style({
|
stroke: new Stroke({
|
color: "red", // 线段颜色
|
width: 6, // 线段宽度
|
}),
|
});
|
|
const feature = new Feature({
|
geometry: line, // 将线段对象作为特征的几何属性
|
});
|
|
feature.setStyle(style);
|
|
window.drawALineLayerMany.getSource().addFeature(feature);
|
}
|
// 多个点
|
const point = value[1];
|
for (const k in point) {
|
const post = point[k].value;
|
|
const iconFeature = new Feature({
|
geometry: new Point([Number(post[0]), Number(post[1])]),
|
attributes: {
|
data: value[2],
|
ourD: {
|
label: value[2].from,
|
},
|
lntLat: [post[0], post[1]],
|
},
|
});
|
|
var textElement = document.createElement("span");
|
textElement.innerHTML = point[k].name;
|
|
iconFeature.setStyle(
|
new Style({
|
cursor: "pointer",
|
|
image: new Icon({
|
scale: 30 / 64,
|
src: "/changjing/img/icon/activity.png",
|
// 设置图标偏移
|
anchor: [32, 32],
|
// X方向单位:分数
|
anchorXUnits: "pixels",
|
// Y方向单位:像素
|
anchorYUnits: "pixels",
|
}),
|
|
text: new Text({
|
// 对齐方式
|
textAlign: "center",
|
// 文本基线
|
textBaseline: "middle",
|
text: textElement.innerHTML,
|
font: "14px Arial",
|
offsetX: 0,
|
offsetY: 24,
|
fill: new Fill({
|
color: "red",
|
}),
|
stroke: new Stroke({ color: "#fff", width: 6 }),
|
}),
|
})
|
);
|
|
window.drawAPointLayerMany.getSource().addFeature(iconFeature);
|
}
|
},
|
},
|
};
|
|
export default mobile;
|