From acb45c731c3ccd0a67061efb4e7bdf4f56005672 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 12 Jan 2022 08:52:13 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/school-web
---
src/components/mobileWindow/index.vue | 28 +++
src/components/mobilemap/index.vue | 9
src/components/campusNav/index.vue | 1
public/index.html | 9
src/components/mobileCortrolButtom/index.vue | 57 ++++-
src/components/mobilePopupOurAfter/index.vue | 19 +
src/components/mobileCloseRouter/index.vue | 121 +++++++++++++
src/store/getters.js | 8
src/store/modules/mobile.js | 173 +++++++++++++++++++
src/components/mobileCortrol/index.vue | 17 +
src/components/mobileGoTo/index.vue | 84 +++++++--
11 files changed, 472 insertions(+), 54 deletions(-)
diff --git a/public/index.html b/public/index.html
index bb32120..173275e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -9,18 +9,21 @@
<title>智慧社区大数据三维可视化平台</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<!-- 高德定位 -->
- <script type="text/javascript"
- src="https://webapi.amap.com/maps?v=1.4.15&key=4b3e1db3211054ce5b466407cbb9d221"></script>
+ <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=4b3e1db3211054ce5b466407cbb9d221">
+ </script>
<!-- ip -->
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<!-- 语音播放 -->
<!-- <script src="http://cdn.javanx.cn/wp-content/themes/lensnews2.2/js/jquery.min.js?ver=3.1.1"></script> -->
+ <!-- 高德地图路线规划 -->
+ <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=4b3e1db3211054ce5b466407cbb9d221">
+ </script>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
- Please enable it to continue.</strong>
+ Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
diff --git a/src/components/campusNav/index.vue b/src/components/campusNav/index.vue
index 2c7da6e..8a92a73 100644
--- a/src/components/campusNav/index.vue
+++ b/src/components/campusNav/index.vue
@@ -211,7 +211,6 @@
},
startNavigation () {
- var that = this
if (this.routeLayer == null) {
this.routeLayer = new this.DC.VectorLayer('navigation')
this.viewer.addLayer(this.routeLayer)
diff --git a/src/components/mobileCloseRouter/index.vue b/src/components/mobileCloseRouter/index.vue
new file mode 100644
index 0000000..c035152
--- /dev/null
+++ b/src/components/mobileCloseRouter/index.vue
@@ -0,0 +1,121 @@
+<template>
+ <!-- v-show="isOpenDrawALine" -->
+ <div class="routers">
+ <div
+ :class="['mobileCloseRouter', isOpenDrawALine ? 'mobileCloseActive' : '']"
+ @click="mobileRouterClose"
+ >
+ 退出导航
+ </div>
+ <div
+ v-for="(item, index) in routerS"
+ :key="item.Str"
+ :style="{ bottom: 357 + index * 37 + 'px' }"
+ :class="[
+ 'mobileCloseRouterOpen',
+ index < lengthS && isOpenDrawALine ? 'mobileCloseActive' : '',
+ choiceRouterS == index ? 'mobileCloseActiveOpen' : '',
+ ]"
+ @click="mobileRouterCloseOpen(item.Str, index)"
+ >
+ <!-- 路径{{ index + 1 }}:{{ item.titles }} -->
+ 路径{{ index + 1 }}
+ </div>
+ </div>
+</template>
+
+<script>
+import { mapGetters } from "vuex";
+export default {
+ name: "mobileCloseRouter",
+ computed: {
+ ...mapGetters(["isOpenDrawALine", "routerS", "choiceRouterS"]),
+ },
+ data() {
+ return {
+ lengthS: 0,
+ };
+ },
+ watch: {
+ isOpenDrawALine() {
+ if (this.isOpenDrawALine) {
+ } else {
+ }
+ },
+ routerS() {
+ if (this.routerS.length == 0) {
+ this.lengthS = 0;
+ }
+ setTimeout(() => {
+ this.lengthS++;
+ }, 200);
+ },
+ },
+ methods: {
+ mobileRouterClose() {
+ this.$store.commit("removePolyline");
+ },
+ mobileRouterCloseOpen(Str, index) {
+ if (this.choiceRouterS == index) {
+ return;
+ }
+ this.$store.commit("set_choiceRouterS", index);
+ this.$store.dispatch("MSET_DRAWALINELAYER", Str);
+ },
+ },
+};
+</script>
+
+<style lang="scss" scoped>
+.routers {
+ width: 0;
+ height: 0;
+}
+.mobileCloseRouter {
+ position: fixed;
+ width: 80px;
+ height: 32px;
+ background-color: #409eff;
+ z-index: 600;
+ right: -100px;
+ opacity: 0;
+ bottom: 320px;
+ font-size: 14px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 8px 0 0 8px;
+ color: #fff;
+ transition: all 0.5s;
+}
+.mobileCloseRouterOpen {
+ position: fixed;
+ // width: 127px;
+ width: 80px;
+ height: 32px;
+ background-color: #fff;
+ z-index: 600;
+ right: -100px;
+ opacity: 0;
+ bottom: 357px;
+ font-size: 14px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 8px 0 0 8px;
+ color: #000;
+ border-left: 1px solid #a4d1ff;
+ border-top: 1px solid #a4d1ff;
+ border-bottom: 1px solid #a4d1ff;
+ transition: all 0.5s;
+}
+.mobileCloseActive {
+ right: 0px;
+ opacity: 1;
+}
+.mobileCloseActiveOpen {
+ border: 1px solid #409eff;
+ background-color: #409eff;
+ color: #fff;
+}
+</style>
diff --git a/src/components/mobileCortrol/index.vue b/src/components/mobileCortrol/index.vue
index f596bff..cabf0fe 100644
--- a/src/components/mobileCortrol/index.vue
+++ b/src/components/mobileCortrol/index.vue
@@ -70,6 +70,7 @@
width: 35px;
height: 35px;
background-color: rgb(33, 150, 243);
+ // background-color: white;
// stroke-width: 10;
// stroke: #fff;
display: flex;
@@ -82,8 +83,13 @@
}
.m-l-inbut-2d {
position: relative;
+ background-color: white;
top: 60px;
font-size: 12px;
+ color: #000;
+ border: 1px solid #a4d1ff;
+ border-radius: 5px 5px 0 0;
+ // box-shadow: 0px 0px 10px #409eff inset;
// &:hover {
// background-color: rgb(21, 136, 230);
// box-shadow: -2px -2px 3px rgb(3, 74, 136) inset;
@@ -91,12 +97,17 @@
}
.m-l-inbut-3d {
@extend .m-l-inbut-2d;
- top: 55px;
+ top: 45px;
+ border-radius: 0 0 5px 5px;
}
.active {
- // background-color: rgb(92, 181, 255);
- box-shadow: -4px -4px 10px rgb(13, 98, 167) inset;
+ background-color: #409eff;
+ border: 1px solid #409eff;
+ color: #fff;
+ border-radius: 5px;
+ z-index: 10;
+ // box-shadow: -4px -4px 10px rgb(13, 98, 167) inset;
// color: rgb(0, 0, 0);
// box-shadow: -4px -4px 10px rgb(13, 98, 167) inset;
transform: translateY(1px);
diff --git a/src/components/mobileCortrolButtom/index.vue b/src/components/mobileCortrolButtom/index.vue
index 84d2273..584f8a9 100644
--- a/src/components/mobileCortrolButtom/index.vue
+++ b/src/components/mobileCortrolButtom/index.vue
@@ -36,26 +36,26 @@
tabTable: [],
ccData: [
{
- lnt: 115.86471885,
- lat: 28.74382592,
+ lnt: 114.03835559,
+ lat: 27.63057034,
},
{
- lnt: 115.86711312,
- lat: 28.74315701,
+ lnt: 114.03971446,
+ lat: 27.62986481,
},
{
- lnt: 115.86872136,
- lat: 28.74009846,
+ lnt: 114.03841654,
+ lat: 27.62919726,
},
{
- lnt: 115.87413129,
- lat: 28.743337,
+ lnt: 114.039946,
+ lat: 27.62847544,
},
],
};
},
computed: {
- ...mapGetters(["mviewer", "openmobileGoTo"]),
+ ...mapGetters(["mviewer", "openmobileGoTo", "dimensionData"]),
},
created() {
this.DC = global.DC;
@@ -69,19 +69,42 @@
},
handleCommand(command) {
let that = this;
- let position = [+command.lnt + 0.01197, +command.lat - 0.0021];
+ let position = [+command.lnt + 0.00027, +command.lat + 0.00048, 450];
console.log(command, "定位");
// 定位
// this.$store.commit("MSETCC_SETCC", {
// lntLat: position,
// });
- this.$store.dispatch("mapFlyTo", {
- //飞入
- lntLat: [...position, 500],
- heading: 0,
- pitch: -45,
- roll: 0,
- noOpen: true,
+ // this.$store.dispatch("mapFlyTo", {
+ // //飞入
+ // lntLat: [...position, 450],
+ // heading: 0,
+ // pitch: -90,
+ // roll: 0,
+ // noOpen: true,
+ // });
+ that.mviewer.camera.setView({
+ // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
+ // fromDegrees()方法,将经纬度和高程转换为世界坐标
+ destination: new global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
+ // 114.0351,
+ // 27.6314,
+ // 200.0
+ position[0],
+ position[1],
+ position[2]
+ ),
+ orientation: {
+ heading: global.DC.Namespace.Cesium.Math.toRadians(
+ that.dimensionData.heading
+ ),
+ pitch: global.DC.Namespace.Cesium.Math.toRadians(
+ that.dimensionData.pitch
+ ),
+ // heading: data.heading,
+ // pitch: data.pitch,
+ roll: that.dimensionData.roll,
+ },
});
},
openBigPopupAfter() {
diff --git a/src/components/mobileGoTo/index.vue b/src/components/mobileGoTo/index.vue
index 3aaf38a..d245106 100644
--- a/src/components/mobileGoTo/index.vue
+++ b/src/components/mobileGoTo/index.vue
@@ -1,16 +1,25 @@
<template>
- <div v-show="openmobileGoTo" class="mobileGoTo">
- <el-input v-model="height"></el-input>
+ <div v-if="openmobileGoTo" class="mobileGoTo">
+ <el-input v-model="int1"></el-input>
+ <el-input v-model="lat1"></el-input>
+ <el-input v-model="int2"></el-input>
+ <el-input v-model="lat2"></el-input>
+ <!-- <el-input v-model="lnt"></el-input>
+ <el-input v-model="lat"></el-input> -->
+ <!-- <el-input v-model="height"></el-input>
<el-input v-model="heading"></el-input>
<el-input v-model="pitch"></el-input>
- <el-input v-model="roll"></el-input>
+ <el-input v-model="roll"></el-input> -->
<!-- <el-input v-model="alt"></el-input> -->
<el-button type="primary" @click="submitForm('')">跳转</el-button>
+ <div class="mobileGoTocontext">{{ context }}</div>
+ <el-button type="primary" @click="dingwei">规划路线</el-button>
</div>
</template>
<script>
import { mapGetters } from "vuex";
+import axios from "axios";
export default {
name: "mobileGoTo",
computed: {
@@ -22,17 +31,33 @@
"ccDataState",
"perspectiveControls",
"perspectiveControl",
+ "dimensionData",
+ "isendPosition",
+ "endPosition",
]),
+ startLngLat() {
+ return [+this.int1, +this.lat1];
+ },
+ endLngLat() {
+ return [+this.int2, +this.lat2];
+ },
},
data() {
return {
- lnt: "121.53772514948211",
- lat: "31.23938286341316",
- alt: "90.648862227",
+ lnt: "114.039946",
+ lat: "27.628475",
+ alt: "0",
height: 800,
heading: 0,
pitch: -45,
roll: 0,
+ context: null,
+ // startLngLat: [114.039946, 27.628475],
+ // endLngLat: [114.038355, 27.63057],
+ int1: 114.039946,
+ lat1: 27.628475,
+ int2: 114.038355,
+ lat2: 27.63057,
};
},
watch: {
@@ -50,29 +75,40 @@
this.pitch = this.perspectiveControl.pitch;
this.roll = this.perspectiveControl.roll;
},
+ isendPosition() {
+ this.int2 = this.endPosition[0];
+ this.lat2 = this.endPosition[1];
+ console.log(this.endPosition);
+ },
},
methods: {
submitForm() {
if (this.lnt && this.lat) {
let that = this;
// 定制化窗体
- // let position = {};
- // let lntLat = [that.lnt, that.lat];
- // let d = {
- // position,
- // lntLat,
- // query: { position, lntLat },
- // useJWD: true, //仅使用经纬度
- // };
- // that.$store.dispatch("setMobileWindows", d);
+ let position = {};
+ let lntLat = [that.lnt, that.lat];
let d = {
- height: this.height,
- heading: this.heading,
- pitch: this.pitch,
- roll: this.roll,
+ position,
+ lntLat,
+ query: { position, lntLat },
+ useJWD: true, //仅使用经纬度
};
- that.$store.dispatch("MSET_GOTOCC", d);
+ that.$store.dispatch("setMobileWindows", d);
+ // let d = {
+ // height: this.height,
+ // heading: this.heading,
+ // pitch: this.pitch,
+ // roll: this.roll,
+ // };
+ // that.$store.dispatch("MSET_GOTOCC", d);
}
+ },
+ // dingwei(startLngLat, endLngLat) {
+ dingwei() {
+ let ints = [this.startLngLat, this.endLngLat];
+ console.log(ints);
+ this.$store.dispatch("MSET_GOTOWHERE", ints);
},
},
};
@@ -84,5 +120,11 @@
bottom: 60px;
width: 73%;
z-index: 500;
+ .mobileGoTocontext {
+ width: 100%;
+ height: 100%;
+ background-color: #fff;
+ word-wrap: break-word;
+ }
}
-</style>
\ No newline at end of file
+</style>
diff --git a/src/components/mobilePopupOurAfter/index.vue b/src/components/mobilePopupOurAfter/index.vue
index 655171e..2209fc8 100644
--- a/src/components/mobilePopupOurAfter/index.vue
+++ b/src/components/mobilePopupOurAfter/index.vue
@@ -1,5 +1,9 @@
<template>
- <div id="mobilePopupOurAfter">
+ <div
+ class="mobilePopupOurAfter"
+ :class="{ ismBigPopupAfter: mBigPopupAfter }"
+ >
+ <!-- v-show="mBigPopupAfter" -->
<div class="m_p_a_heard">
<div><i class="el-icon-menu icon"></i></div>
<div @click="closeBigPopupAfter"><i class="el-icon-close icon"></i></div>
@@ -32,6 +36,7 @@
</template>
<script>
+import { mapGetters } from "vuex";
import { getList } from "@/api/mobile/orgnav/index"; //机构单位
import { getChildNavList } from "@/api/mobile/public/arc"; //社区建筑
import {
@@ -51,6 +56,9 @@
// import { getListparking } from "@/api/mobile/stop/index"; //停车场
export default {
name: "mobilePopupOurAfter",
+ computed: {
+ ...mapGetters(["mBigPopupAfter"]),
+ },
data() {
return {
choiceValue: "",
@@ -158,14 +166,16 @@
align-items: center;
justify-content: center;
}
-#mobilePopupOurAfter {
+.mobilePopupOurAfter {
position: fixed;
top: 37.5%;
- left: 13.5%;
+ // left: 13.5%;
+ left: -1000px;
width: 75%;
height: 25%;
background-color: #fff;
box-shadow: 0px 0px 5px #29baf1;
+ transition: all 0.5s;
// background-image: linear-gradient(
// // 135deg,
// #28bbf06c 30px,
@@ -230,4 +240,7 @@
}
}
}
+.ismBigPopupAfter {
+ left: 13.5%;
+}
</style>
diff --git a/src/components/mobileWindow/index.vue b/src/components/mobileWindow/index.vue
index 39fc902..6d2880b 100644
--- a/src/components/mobileWindow/index.vue
+++ b/src/components/mobileWindow/index.vue
@@ -6,7 +6,11 @@
>
<div class="mobiletitle">
{{ title }}
- <span class="mobile_audio" @click="openAudio" v-show="introduce">
+ <span
+ class="mobile_audio"
+ @click="openAudio"
+ v-show="introduce && !video"
+ >
<i class="el-icon-video-play icon" v-show="!audioState"></i>
<i class="el-icon-video-pause icon" v-show="audioState"></i>
<!-- <div id="bdtts_div_id">
@@ -204,9 +208,31 @@
methods: {
openOnce(val) {
let that = this;
+ that.routerS = [];
+ let once = true;
if (val == "去这") {
//定位
console.log(this.query.query);
+ // that.$store.commit("set_endPosition", this.query.query.lntLat);
+ let ints = {
+ // start: [114.039946, 27.628475],
+ // end: that.query.query.lntLat,
+ start: [+that.query.query.lntLat[0], +that.query.query.lntLat[1]],
+ end: [114.031946, 27.621475],
+ type: "driving",
+ fn: function (datas) {
+ //获取回调路径
+ that.routerS.push(datas);
+ if (once) {
+ once = false;
+ //加载第一条线路
+ that.$store.commit("set_choiceRouterS", 0);
+ that.$store.dispatch("MSET_DRAWALINELAYER", datas.Str);
+ that.$store.commit("cameraSetView", ints.start);
+ }
+ },
+ };
+ that.$store.dispatch("MSET_GOTOWHERE", ints);
} else if (val == "实景") {
this.$store.commit(
"MSET_OPENMOBILEPANORAMA",
diff --git a/src/components/mobilemap/index.vue b/src/components/mobilemap/index.vue
index 3edfe80..f3a8643 100644
--- a/src/components/mobilemap/index.vue
+++ b/src/components/mobilemap/index.vue
@@ -14,13 +14,16 @@
<mobileCortrolSearch ref="mobileCortrolSearch"></mobileCortrolSearch>
<!-- 控制↑ -->
<!-- 控制大弹窗的弹窗 -->
- <mobilePopupOurAfter v-if="mBigPopupAfter"></mobilePopupOurAfter>
+ <!-- v-if="mBigPopupAfter" -->
+ <mobilePopupOurAfter></mobilePopupOurAfter>
<!-- 大弹窗 -->
<mobilePopupOur :style="[bigPopup]" v-if="mBigPopup"></mobilePopupOur>
<!-- 测试-跳转位置 -->
- <!-- <mobileGoTo></mobileGoTo> -->
+ <mobileGoTo></mobileGoTo>
<!-- 实景窗口 -->
<mobilePanorama></mobilePanorama>
+ <!-- 退出导航 -->
+ <mobileCloseRouter></mobileCloseRouter>
<!-- 盖住左下角 -->
<div class="cover_mobileMap">智慧社区</div>
</div>
@@ -325,7 +328,7 @@
luminanceAtZenith: 0.5,
});
- tilesetLayer.addOverlay(tileset);
+ // tilesetLayer.addOverlay(tileset);
// tilesetLayer.show = false;
let silhouetteBlue =
diff --git a/src/store/getters.js b/src/store/getters.js
index 6e832be..9f54707 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -20,7 +20,13 @@
dimension: (state) => state.mobile.dimension, // 维度
dimensionData: (state) => state.mobile.dimensionData, // 维度镜头数据
perspectiveControl: (state) => state.mobile.perspectiveControl, /// 视角控制:高度、角度 ()=>{}
- audioState: (state) => state.mobile.audioState // 文字转语音状态
+ audioState: (state) => state.mobile.audioState, // 文字转语音状态
+
+ isOpenDrawALine: (state) => state.mobile.isOpenDrawALine, // 是否开启路线
+ isendPosition: (state) => state.mobile.isendPosition, // 路线导航终点数据改变
+ endPosition: (state) => state.mobile.endPosition, // 路线导航终点数据
+ routerS: (state) => state.mobile.routerS, // 所有路径
+ choiceRouterS: (state) => state.mobile.choiceRouterS // 当前选择路径
}
const navigation = {
diff --git a/src/store/modules/mobile.js b/src/store/modules/mobile.js
index 19643e4..ed8c228 100644
--- a/src/store/modules/mobile.js
+++ b/src/store/modules/mobile.js
@@ -1,4 +1,5 @@
import $store from "../index";
+import axios from "axios";
const mobile = {
state: {
mviewer: null, // 地图实体类
@@ -51,6 +52,15 @@
audioData: null, //语音
audioState: false, //语音状态
+
+ navigationStartLngLat: "", //导航起点
+ navigationEndLngLat: "", //导航终点
+ drawALineLayer: null, //导航路径图层
+ isOpenDrawALine: false, //是否开启路径
+ endPosition: "", //传送终点经纬度--
+ isendPosition: false, //传送终点经纬度--感应数据
+ routerS: [], //所有路径
+ choiceRouterS: 0, //当前选择路径
},
mutations: {
MSET_VIEWER(state, viewer) {
@@ -222,6 +232,49 @@
state.tileset = data.tileset;
state.usetowpointfive = data.usetowpointfive;
},
+ //直接移动
+ cameraSetView(state, data) {
+ state.mviewer.camera.setView({
+ // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
+ // fromDegrees()方法,将经纬度和高程转换为世界坐标
+ destination: new global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
+ // 114.0351,
+ // 27.6314,
+ // 200.0
+ data[0] + 0.0,
+ data[1] + 0.00028,
+ 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 (state.drawALineLayer) {
+ state.drawALineLayer.remove();
+ state.drawALineLayer = null;
+ state.isOpenDrawALine = false;
+ }
+ },
+ //传送终点数据
+ set_endPosition(state, data) {
+ state.isendPosition = !state.isendPosition;
+ state.endPosition = data;
+ },
+ //传送当前选择的路径
+ set_choiceRouterS(state, data) {
+ state.choiceRouterS = data;
+ },
},
actions: {
MSET_CREADE({ state, commit, dispatch }) {
@@ -321,6 +374,7 @@
0,
state.dimensionData.pitch
);
+ // console.log(state.dimension);
if (state.dimension != "2.5D") {
// if (true) {
dispatch("mapFlyTo", {
@@ -331,7 +385,6 @@
roll: Position.roll,
});
} else {
- // console.log(17878);
state.mviewer.camera.setView({
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
// fromDegrees()方法,将经纬度和高程转换为世界坐标
@@ -548,6 +601,7 @@
},
});
},
+ //文字转语音控制↓
MSET_GETAUDIO({ state, commit, dispatch }, val) {
state.audioData = new window.SpeechSynthesisUtterance();
state.audioData.text = val;
@@ -568,6 +622,123 @@
}
}
},
+ //文字转语音控制↑
+ //导航系统↓
+ MSET_GOTOWHERE({ state, commit, dispatch }, val) {
+ state.routerS = []; //清空存着的路径
+ //单条步行
+ //本地图使用的是WGS84坐标,而高德使用的是火星坐标GCJ02,所以需要转换参数过去
+ // 返回值需要转换为WGS84坐标
+ state.navigationStartLngLat = [+val.start[0], +val.start[1]]; //导航起点
+ state.navigationEndLngLat = [+val.end[0], +val.end[1]]; //导航终点
+ //转换WGS84坐标为GCJ02
+ let GCJ02StartLngLat = global.DC.CoordTransform.WGS84ToGCJ02(
+ Number(state.navigationStartLngLat[0]),
+ Number(state.navigationStartLngLat[1])
+ );
+ let GCJ02EndLngLat = global.DC.CoordTransform.WGS84ToGCJ02(
+ Number(state.navigationEndLngLat[0]),
+ Number(state.navigationEndLngLat[1])
+ );
+ // 获取路径,使用的是高德API
+
+ let url = "https://restapi.amap.com/v3/direction/walking"; //默认api步行
+ let data = {
+ origin: `${Number(GCJ02StartLngLat[0]).toFixed(6)},${Number(
+ GCJ02StartLngLat[1]
+ ).toFixed(6)}`,
+ destination: `${Number(GCJ02EndLngLat[0]).toFixed(6)},${Number(
+ GCJ02EndLngLat[1]
+ ).toFixed(6)}`,
+ key: "4b3e1db3211054ce5b466407cbb9d221",
+ output: "json",
+ };
+ let strategyType = [0];
+ if (val.type) {
+ //切换驾车模式
+ url = "https://restapi.amap.com/v3/direction/driving";
+ data["strategy"] = 10;
+ strategyType = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ }
+ // for (let index = 0; index < strategyType.length; index++) {
+ // data["strategy"] = strategyType[index];
+ axios
+ .get(url, {
+ params: { ...data },
+ })
+ .then((res) => {
+ //回调
+ const paths = res.data.route.paths;
+ for (let i = 0; i < paths.length; i++) {
+ //多条路线
+ drawALine(paths[i]);
+ }
+ // const paths = res.data.route.paths[0].steps;
+ // drawALine(paths, res.data.route.paths[0].strategy);
+ });
+ // }
+ let drawALine = (pathsour) => {
+ let paths = pathsour.steps;
+ let titles = pathsour.strategy;
+ //paths是个道路对象,其中polyline是String类型的经纬度
+ let Str = state.navigationStartLngLat.join(",") + ";"; //加入起点
+ for (let index = 0; index < paths.length; index++) {
+ const path = paths[index];
+ let polyline = path.polyline; //取到String类型的经纬度
+ let polylineArr = polyline.split(";"); //转为数组
+ let polylineArrLength = polylineArr.length; //获取长度,避免多次重复读取polylineArr.length
+ for (let k = 0; k < polylineArrLength; k++) {
+ let inPolylineArr = polylineArr[k].split(","); //转经纬度为单独的数组
+ let outIn = global.DC.CoordTransform.GCJ02ToWGS84(
+ //处理火星坐标转换成WGS84 GCJ02ToWGS84
+ inPolylineArr[0],
+ inPolylineArr[1]
+ );
+ polylineArr[k] = outIn.join(","); //每组经纬度转为String
+ }
+ polyline = polylineArr.join(";"); //合并转换后的经纬度合集
+
+ Str += polyline; //自加
+ Str += ";";
+ }
+ Str += state.navigationEndLngLat.join(","); //加入终点
+ if (val.fn) {
+ let dataS = {
+ //返回数据
+ titles: titles,
+ Str: Str,
+ };
+ state.routerS.push(dataS);
+ return val.fn(dataS);
+ } else {
+ dispatch("MSET_DRAWALINELAYER", Str); //绘画线路
+ }
+ };
+ },
+ //导航系统↑
+ //绘画线路
+ MSET_DRAWALINELAYER({ state, commit, dispatch }, Str) {
+ //检查是否存在路线
+ commit("removePolyline");
+ let color =
+ global.DC.Namespace.Cesium.Color.fromCssColorString("#409EFF");
+ let material = new global.DC.PolylineTrailMaterialProperty({
+ color: color,
+ speed: 10,
+ });
+ let drawALineLayer = new global.DC.VectorLayer("layer");
+ state.mviewer.addLayer(drawALineLayer);
+ let polyline = new global.DC.Polyline(Str); //加入绘画点
+ polyline.setStyle({
+ width: 3,
+ material: material,
+ clampToGround: true,
+ });
+ drawALineLayer.addOverlay(polyline);
+ state.drawALineLayer = drawALineLayer;
+ state.isOpenDrawALine = true;
+ // commit("cameraSetView", state.navigationStartLngLat); //移动
+ },
},
};
--
Gitblit v1.9.3