664d33538b3084032674e1c8b2e46bf8839b58e8.svn-base 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. <template>
  2. <div id="mapToolBarContainer_hhjc">
  3. <div id="mapTopToolBar">
  4. <div style="padding-left: 10px;display: flex;flex-direction: row;justify-content: space-between;align-items: center;">
  5. <!-- <p style="margin-left:0%;margin-right:10px;display:inline;color:rgb(129, 131, 135);">
  6. 导航:
  7. </p> -->
  8. <img src="../assets/daohang.png" style="width: 20px;">
  9. <el-button :icon="this.showXzqPanel ?'el-icon-arrow-up':'el-icon-arrow-down'"
  10. @click="showPanel('navi')" style="border-radius: 5px;padding: 5px 5px;" size="small ">{{currentStatus.currentTitle}}</el-button>
  11. </div>
  12. <div style="padding-left: 20px;display: flex;flex-direction: row;justify-content: space-between;align-items: center;">
  13. <img src="../assets/tool.png" style="width: 20px;">
  14. <el-button :icon="this.showToolPanel ?'el-icon-arrow-up':'el-icon-arrow-down'"
  15. @click="showToolPanelHandler()" style="border-radius: 5px;padding: 5px 5px;" size="small ">工具箱</el-button>
  16. </div>
  17. <!-- <div style="width: 70px;margin-left:40px;display: flex;flex-direction: row;justify-content: space-between;align-items: center;">
  18. <p style="margin-left:0%;margin-right:10px;display:inline;color:rgb(129, 131, 135);">
  19. <i class="el-icon-location"></i>地图工具:
  20. </p>
  21. <img src="../assets/distance.png" class="imgClass" title="测距" @click="mapToolHandler('distance')">
  22. <img src="../assets/area.png" class="imgClass" title="测面" @click="mapToolHandler('area')">
  23. <img src="../assets/clear.png" class="imgClass" title="清除" @click="mapToolHandler('clear')">
  24. </div> -->
  25. </div>
  26. <div class="xzqPanelClass">
  27. <div v-if="showXzqPanel">
  28. <div style="min-height:30px;display:flex;flex-direction:row;justify-content:space-between;align-items:center;border-bottom:1px solid rgb(240,240,240)">
  29. <div style="display:flex;flex-direction:row;">
  30. <p style="font-size:14px;margin-left:10px;padding-top: 5px;color:rgb(173,177,192)">当前:</p>
  31. <p class="naviClickableLink" v-for="step in naviStateStack" @click="backToStep(step)" style="color: blue;font-size:14px;padding-left:5px;">{{step.title}}</p>
  32. </div>
  33. <!-- <div style="display:flex;flex-direction:row;padding-right: 5px;cursor: pointer;">
  34. <span class="el-icon-circle-close-outline" @click="closeNavigationPanel"></span>
  35. </div> -->
  36. </div>
  37. <div style="display:flex;flex-direction:row;margin-top:5px;">
  38. <p style="font-size:small;color:rgb(173,177,192);margin-left:10px;">行政区列表:</p>
  39. </div>
  40. <div style="display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:wrap;border-bottom:1px solid rgb(240,240,240);max-height:300px;overflow:auto;">
  41. <p class="naviClickableLink" style="flex-shrink:1;flex-grow:0;color: blue;" v-for="nextxzq in nextLevelXzq" :key="nextxzq.adCode" @click="clickAd(nextxzq)">{{nextxzq.adName}}</p>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="toolPanelClass">
  46. <div v-if=showToolPanel>
  47. <transition name="el-zoom-in-top">
  48. <ul role="menu" id="cascader-menu-1602" class="mapRightMenu" style="margin-left: 118px;width: 80px;">
  49. <li tabindex="-1" role="menuitem" aria-haspopup="true" aria-owns="menu-8696-1"
  50. class="menuItem" @click="click('fullExtent')">
  51. <img src="../assets/fullExtent.png" alt="" style="height:17px;margin-right:5px;">
  52. <p class="pClass">全图</p>
  53. </li>
  54. <li tabindex="-1" role="menuitem" aria-haspopup="true" aria-owns="menu-8696-1"
  55. class="menuItem" @click="click('biaoji')">
  56. <img src="../assets/bjR.png" alt="" style="height:17px;margin-right: 9px;margin-left: 5px;">
  57. <p class="pClass">标记</p>
  58. </li>
  59. <li tabindex="-1" role="menuitem" aria-haspopup="true" aria-owns="menu-8696-1"
  60. class="menuItem" @click="click('daohang')">
  61. <img src="../assets/daohang1.png" alt="" style="height:17px;margin-right:5px;">
  62. <p class="pClass">导航</p>
  63. </li>
  64. <li tabindex="-1" role="menuitem" aria-haspopup="true" aria-owns="menu-8696-1"
  65. class="menuItem" @click="click('measureDistance')">
  66. <img src="../assets/distance.png" alt="" style="height:17px;margin-right:5px;">
  67. <p class="pClass">测距</p>
  68. </li>
  69. <li tabindex="-1" role="menuitem" aria-haspopup="true" aria-owns="menu-8696-1"
  70. class="menuItem" @click="click('measureArea')">
  71. <img src="../assets/area.png" alt="" style="height:17px;margin-right:5px;">
  72. <p class="pClass">测面</p>
  73. </li>
  74. <li tabindex="-1" role="menuitem" aria-haspopup="true" aria-owns="menu-8696-1"
  75. class="menuItem" @click="click('clear')">
  76. <img src="../assets/clear.png" alt="" style="height:17px;margin-right:5px;">
  77. <p class="pClass">清除</p>
  78. </li>
  79. </ul>
  80. </transition>
  81. </div>
  82. </div>
  83. <div id="daohangContainer" class="daohangContainerClass" v-if="showDaoHangPanel">
  84. <div style="height:30px;float:right;">
  85. <i class="el-icon-close" @click="closeDaoHangPanel" style="padding-right: 5px;color: #dbdbdb;cursor:pointer;"></i>
  86. <!-- <ul class="tabs dir_tab col3 z-depth-1 clearfix" id="trafficTab"> -->
  87. <!-- <li :class="{'trafficActivity':showDaoHanButton=='car'}" style="display: flex;align-items: center;justify-content: center;">
  88. <img src="../assets/car.png" alt="" @click="chooseTraffic('car')" style="height:19px;width:19px;cursor:pointer;">
  89. </li> -->
  90. <!-- <li :class="{'trafficActivity':showDaoHanButton=='bus'}" style="display: flex;align-items: center;justify-content: center;">
  91. <img src="../assets/bus.png" alt="" @click="chooseTraffic('bus')" style="height:20px;width:19px;cursor:pointer;">
  92. </li>
  93. <li :class="{'trafficActivity':showDaoHanButton=='walk'}" style="display: flex;align-items: center;justify-content: center;">
  94. <img src="../assets/walk.png" alt="" @click="chooseTraffic('walk')" style="height:19px;width:24px;cursor:pointer;">
  95. </li> -->
  96. <!-- </ul> -->
  97. </div>
  98. <div style="display: flex;width: 100%;align-items: center;padding-top: 10px;">
  99. <div>
  100. <img src="../assets/jiaohuan.png" alt="" @click="startChangeEndHandler" style="height:40px;width:40px;cursor:pointer;">
  101. </div>
  102. <div>
  103. <el-input placeholder="请输入起点" v-model="startText" clearable @focus="startFocusHandler"
  104. style="padding-bottom: 5px;width: 250px;height: 35px;"></el-input>
  105. <el-input placeholder="请输入终点" v-model="endText" clearable @focus="endFocusHandler"
  106. style="padding-bottom: 5px;width: 250px;height: 35px;"></el-input>
  107. </div>
  108. </div>
  109. <div style="float: right;padding-top: 10px;padding-right: 30px;">
  110. <el-button type="primary" v-show="showDaoHanButton == 'car'" @click="trafficButtonClick('car')" size="mini">导航</el-button>
  111. <el-button type="primary" v-show="showDaoHanButton == 'bus'" @click="trafficButtonClick('bus')" size="mini">公交</el-button>
  112. <el-button type="primary" v-show="showDaoHanButton == 'walk'" @click="trafficButtonClick('walk')" size="mini">步行</el-button>
  113. </div>
  114. </div>
  115. <div id="poiContainer" class="poiClass" v-if="showPoiList">
  116. <div class="poiListClass" v-for="(item,index) in pois" :key="index" @click="poiListClick(item)">
  117. <span style="color: blue;">{{item.name}}</span>
  118. <span style="font-size: small;color: #aaaaaa;padding-left: 10px;">{{item.cityname}}{{item.adname}}</span>
  119. </div>
  120. </div>
  121. <div id="stepContainer" class="stepClass" v-if="showStepPanel">
  122. <div style="display:flex;justify-content: space-around;">
  123. <div style="padding: 5px;padding-top: 10px;">
  124. <span>约</span>
  125. <span style="color:blue;">{{(trafficSteps.duration/3600).toFixed(1)}}</span>
  126. <span>个小时</span>
  127. </div>
  128. <div style="margin-top: 13px;width: 2px;height: 15px;background: #000;"></div>
  129. <div style="padding: 5px;padding-top: 10px;">
  130. <span style="color:blue;">{{(trafficSteps.distance/1000).toFixed(1)}}</span>
  131. <span>公里</span>
  132. </div>
  133. <!-- <div style="margin-top: 13px;width: 1.5px;height: 15px;background: #000;"></div>
  134. <div style="padding: 5px;padding-top: 10px;">
  135. <span>红绿灯</span>
  136. <span style="color:red;">{{trafficSteps.traffic_lights}}</span>
  137. <span>个</span>
  138. </div> -->
  139. </div>
  140. <div style="padding-left: 20px;">
  141. <el-collapse accordion>
  142. <el-collapse-item v-for="(item,index) in trafficSteps.steps" :key="index">
  143. <template slot="title">
  144. {{typeof(item.road) == "undefined"?"无名路":item.road}}<span style="padding-left: 20px;color: #938f8f;">{{(item.distance/1000).toFixed(1)}}km</span>
  145. </template>
  146. <div style="cursor:pointer;" @click="detailRouteOnMap(item)">{{item.instruction}}</div>
  147. </el-collapse-item>
  148. </el-collapse>
  149. </div>
  150. </div>
  151. <div id="biaojiContainer" class="stepClass" v-if="showBiaoJiPanel">
  152. <div style="padding-left: 20px;">
  153. <el-collapse accordion>
  154. <el-collapse-item v-for="(item,index) in tableResultData" :key="index">
  155. <template slot="title">
  156. {{item.inteName}}
  157. </template>
  158. <div style="cursor:pointer;" @click="clickBiaoJiHandler(item)">{{item.des}}</div>
  159. </el-collapse-item>
  160. </el-collapse>
  161. </div>
  162. </div>
  163. </div>
  164. </template>
  165. <script>
  166. const options = {
  167. url: "/arcgisApi/4.7/init.js"
  168. };
  169. import { getAdData} from "../../../api/duChaAPI.js";
  170. import {getMyBiaoJi} from '../../../api/zhxxAPI.js'
  171. import {_getLngLat} from '../js/mercatorToLngLat'
  172. import request from "../../../utils/gw_ajax_request.js"
  173. import axios from 'axios'
  174. import _default,* as esriLoader from "esri-loader";
  175. export default {
  176. components: {
  177. },
  178. props:['view','map','fullExtent'],
  179. data () {
  180. return {
  181. currentText:'',//当前输入的是 起点还是终点
  182. currentStartLocation:'',//起点经纬度 字符串
  183. currentEndLocation:'',//终点经纬度
  184. showDaoHangPanel:false,
  185. showDaoHanButton:'car',
  186. startText:'',
  187. endText:'',
  188. currentStatus:{
  189. currentType:'global',
  190. currentTitle:'全国',
  191. currentCode:'000000000000',
  192. },
  193. naviStateStack:[{title:'全国',type:'global',code:'000000000000'}],
  194. currentAdCode:'',
  195. currentAdName:'',
  196. nextLevelXzq:[],
  197. showXzqPanel:false,
  198. showToolPanel:false,
  199. viewObject:null,
  200. mapObject:null,
  201. fullExtent1:null,
  202. measureGraphicLayer:null,
  203. measureLengthGraphicLayer_lable:null,
  204. draw:null,//测量对象
  205. pois:[],
  206. showPoiList:false,
  207. trafficSteps:{},//交通路线
  208. showStepPanel:false,
  209. showBiaoJiPanel:false,//标记list
  210. tableResultData:[],//标记列表
  211. currentFocus:''//当前focus位置 起点还是终点
  212. }
  213. },
  214. computed:{
  215. userId: function () {
  216. return localStorage.getItem("userid") ?localStorage.getItem("userid") : "1098101939614724096";
  217. },
  218. },
  219. mounted:function() {
  220. this.currentAdCode = localStorage.getItem('areacode') ? localStorage.getItem('areacode') : '000000000000';
  221. this.currentAdName = localStorage.getItem('areaname') ? localStorage.getItem('areaname') : '全国';
  222. if(this.currentAdCode == "undefined"){
  223. this.currentAdCode = '000000000000';
  224. }
  225. this.currentStatus.currentCode = this.currentAdCode;
  226. this.currentStatus.currentTitle = this.currentAdName;
  227. this.getAdData();
  228. this.viewObject = this.view;
  229. this.mapObject = this.map;
  230. this.startText = '';
  231. this.endText = '';
  232. },
  233. watch: {
  234. view(n,o){
  235. this.viewObject = n;
  236. },
  237. map(n,o){
  238. this.mapObject = n;
  239. },
  240. fullExtent(n,o){
  241. this.fullExtent1 = n;
  242. },
  243. startText(n,o){
  244. this.inputChange(n,'start')
  245. },
  246. endText(n,o){
  247. this.inputChange(n,'end')
  248. },
  249. },
  250. methods: {
  251. closeDaoHangPanel(){
  252. this.showDaoHangPanel = false;
  253. this.showPoiList = false;
  254. this.showStepPanel = false;
  255. this.showBiaoJiPanel = false;
  256. var daohangGraphicLayer = this.mapObject.findLayerById("daohangGraphicLayer");
  257. daohangGraphicLayer.removeAll();
  258. daohangGraphicLayer.visible = false;
  259. var daohangGraphicLayer1 = this.mapObject.findLayerById("daohangGraphicLayer1");
  260. daohangGraphicLayer1.removeAll();
  261. daohangGraphicLayer1.visible = false;
  262. },
  263. detailRouteOnMap(item){//定位具体路线
  264. var _self = this;
  265. esriLoader.loadModules(["esri/Graphic","esri/views/2d/draw/Draw","esri/geometry/SpatialReference",
  266. "esri/geometry/Polyline","esri/layers/GraphicsLayer","esri/geometry/geometryEngine",
  267. "esri/geometry/Point","dojo/domReady!"],options).then((
  268. [Graphic,Draw,SpatialReference,Polyline,GraphicsLayer,geometryEngine,Point]) => {
  269. var arr1 = item.tmcs;
  270. var gras = [];
  271. for(var n=0;n<arr1.length;n++){
  272. var str = arr1[n].polyline;
  273. var arr2 = str.split(";");
  274. var vertices = [];
  275. for(var j=0;j<arr2.length;j++){
  276. var arr3 = arr2[j].split(",");
  277. var arr4 = [];
  278. for(var m=0;m<arr3.length;m++){
  279. arr4.push(parseFloat(arr3[m]));
  280. }
  281. vertices.push(arr4);
  282. }
  283. var polyline = new Polyline({
  284. paths: [vertices],
  285. spatialReference: 4326
  286. });
  287. var gra = new Graphic({
  288. geometry: polyline,
  289. symbol: {
  290. type: "simple-line",
  291. color: "green",
  292. width: "5px",
  293. style: "solid",
  294. cap:"round"
  295. }
  296. });
  297. gras.push(gra);
  298. }
  299. _self.viewObject.goTo({
  300. target:gras
  301. }).then((r)=>{
  302. var lod = _self.viewObject.zoom - 2;
  303. console.log(lod);
  304. _self.viewObject.goTo({
  305. target:gras,
  306. zoom:lod
  307. })
  308. })
  309. }).catch(err => {
  310. console.error(err);
  311. });
  312. },
  313. showRouteOnMap(){//地图上展示导航路线
  314. var _self = this;
  315. esriLoader.loadModules(["esri/Graphic","esri/views/2d/draw/Draw","esri/geometry/SpatialReference",
  316. "esri/geometry/Polyline","esri/layers/GraphicsLayer","esri/geometry/geometryEngine",
  317. "esri/geometry/Point","dojo/domReady!"],options).then((
  318. [Graphic,Draw,SpatialReference,Polyline,GraphicsLayer,geometryEngine,Point]) => {
  319. var daohangGraphicLayer = _self.mapObject.findLayerById("daohangGraphicLayer");
  320. daohangGraphicLayer.removeAll();
  321. daohangGraphicLayer.visible = true;
  322. var daohangGraphicLayer1 = _self.mapObject.findLayerById("daohangGraphicLayer1");
  323. daohangGraphicLayer1.removeAll();
  324. daohangGraphicLayer1.visible = true;
  325. if(_self.currentStartLocation && _self.currentEndLocation){
  326. var arr3 = _self.currentStartLocation.split(",");
  327. var arr4 = [];
  328. for(var m1=0;m1<arr3.length;m1++){
  329. arr4.push(parseFloat(arr3[m1]));
  330. }
  331. var pt_start = new Point(arr4[0],arr4[1],new SpatialReference(4326));
  332. var gra_start = new Graphic({
  333. geometry:pt_start,
  334. symbol:{
  335. type: "picture-marker",
  336. url: "/src/views/zongHeXinXiNew/assets/xhstart.png",
  337. width: "40px",
  338. height: "40px"
  339. }
  340. })
  341. daohangGraphicLayer1.add(gra_start);
  342. var arr5 = _self.currentEndLocation.split(",");
  343. var arr6 = [];
  344. for(var m2=0;m2<arr5.length;m2++){
  345. arr6.push(parseFloat(arr5[m2]));
  346. }
  347. var pt_end = new Point(arr6[0],arr6[1],new SpatialReference(4326));
  348. var gra_end = new Graphic({
  349. geometry:pt_end,
  350. symbol:{
  351. type: "picture-marker",
  352. url: "/src/views/zongHeXinXiNew/assets/xhend.png",
  353. width: "40px",
  354. height: "40px"
  355. }
  356. })
  357. daohangGraphicLayer1.add(gra_end);
  358. }
  359. var symbol_green = {
  360. type: "simple-line",
  361. color: "green",
  362. width: "5px",
  363. style: "solid",
  364. cap:"round"
  365. };
  366. var symbol_yellow = {
  367. type: "simple-line",
  368. color: "yellow",
  369. width: "5px",
  370. style: "solid",
  371. cap:"round"
  372. };
  373. var symbol_red = {
  374. type: "simple-line",
  375. color: "red",
  376. width: "5px",
  377. style: "solid",
  378. cap:"round"
  379. };
  380. var symbol_red1 = {
  381. type: "simple-line",
  382. color: "#700000",
  383. width: "5px",
  384. style: "solid",
  385. cap:"round"
  386. };
  387. var arr = _self.trafficSteps.steps;
  388. for(var i=0;i<arr.length;i++){
  389. var arr1 = arr[i].tmcs;
  390. for(var n=0;n<arr1.length;n++){
  391. var str = arr1[n].polyline;
  392. var arr2 = str.split(";");
  393. var vertices = [];
  394. for(var j=0;j<arr2.length;j++){
  395. var arr3 = arr2[j].split(",");
  396. var arr4 = [];
  397. for(var m=0;m<arr3.length;m++){
  398. arr4.push(parseFloat(arr3[m]));
  399. }
  400. vertices.push(arr4);
  401. }
  402. var polyline = new Polyline({
  403. paths: [vertices],
  404. spatialReference: 4326
  405. });
  406. var symbol;
  407. if(arr1[n].status == "缓行"){
  408. symbol = symbol_yellow
  409. }else if(arr1[n].status == "拥堵"){
  410. symbol = symbol_red
  411. }else if(arr1[n].status == "严重拥堵"){
  412. symbol = symbol_red1
  413. }else{
  414. symbol = symbol_green
  415. }
  416. var gra = new Graphic({
  417. geometry: polyline,
  418. symbol: symbol
  419. });
  420. daohangGraphicLayer.add(gra);
  421. }
  422. }
  423. _self.viewObject.goTo({
  424. target:daohangGraphicLayer1.graphics
  425. }).then((r)=>{
  426. var lod = _self.viewObject.zoom - 1;
  427. console.log(lod);
  428. _self.viewObject.goTo({
  429. target:daohangGraphicLayer.graphics,
  430. zoom:lod
  431. })
  432. })
  433. }).catch(err => {
  434. console.error(err);
  435. });
  436. },
  437. trafficButtonClick(val){//驾车 公交 步行
  438. var _self = this;
  439. if(_self.startText == ''){
  440. if(_self.showPoiList){
  441. _self.$message.warning('请选择起点!');
  442. }else{
  443. _self.$message.warning('请输入起点!');
  444. }
  445. return;
  446. }
  447. if(_self.endText == ''){
  448. if(_self.showPoiList){
  449. _self.$message.warning('请选择终点!');
  450. }else{
  451. _self.$message.warning('请输入终点!');
  452. }
  453. return;
  454. }
  455. if(val == "car"){
  456. axios.get('/GDAPI/v3/direction/driving',{
  457. params: {
  458. origin:_self.currentStartLocation,
  459. destination:_self.currentEndLocation,
  460. output:'json',
  461. key:'481d08235e1dc266e0f979db1d86162c',
  462. }
  463. }).then((res)=>{
  464. console.log('car');
  465. if(res.data.status == "1"){
  466. _self.showStepPanel = true;
  467. _self.trafficSteps = res.data.route.paths[0];
  468. _self.showRouteOnMap();
  469. }
  470. })
  471. }else if(val == "bus"){
  472. axios.get('/GDAPI/v3/direction/transit/integrated',{
  473. params: {
  474. origin:_self.currentStartLocation,
  475. destination:_self.currentEndLocation,
  476. output:'json',
  477. key:'481d08235e1dc266e0f979db1d86162c',
  478. }
  479. }).then((res)=>{
  480. console.log('bus');
  481. if(res.data.status == "1"){
  482. }
  483. })
  484. }else if(val == "walk"){
  485. }
  486. },
  487. poiListClick(item){//模糊查询列表 点击
  488. var _self = this;
  489. if(_self.currentText == "start"){
  490. _self.startText = item.name;
  491. _self.currentStartLocation = item.location;
  492. }else{
  493. _self.endText = item.name;
  494. _self.currentEndLocation = item.location;
  495. }
  496. _self.showPoiList = false;
  497. },
  498. inputChange(val,type){//input输入内后后 关键字模糊查询
  499. var _self = this;
  500. _self.showPoiList = true;//打开poi
  501. _self.showBiaoJiPanel = false;//关闭标记
  502. _self.showStepPanel = false;//关闭详情路线
  503. _self.currentText = type;
  504. // if(type == "start"){
  505. // _self.currentStartLocation = '';
  506. // }else{
  507. // _self.currentEndLocation = '';
  508. // }
  509. axios.get('/GDAPI/v3/place/text',{
  510. params: {
  511. keywords:val,
  512. output:'json',
  513. offset:10,
  514. page:1,
  515. key:'481d08235e1dc266e0f979db1d86162c',
  516. }
  517. }).then((res)=>{
  518. console.log('succ');
  519. if(res.data.status =='1'){
  520. _self.pois = res.data.pois;
  521. }
  522. })
  523. },
  524. clickBiaoJiHandler(item){//点击标记列表 给起点终点赋值
  525. var _self = this;
  526. var lgtd102100 = item.lgtd;
  527. var lttd102100 = item.lttd;
  528. var topRight = _getLngLat({
  529. x:lgtd102100,
  530. y:lttd102100
  531. })
  532. var lgtd84 = topRight.lng;
  533. var lttd84 = topRight.lat;
  534. if(_self.currentFocus == 'start'){
  535. _self.currentStartLocation = String(lgtd84.toFixed(6))+","+String(lttd84.toFixed(6));
  536. _self.startText = item.inteName;
  537. }else if(_self.currentFocus == 'end'){
  538. _self.currentEndLocation = String(lgtd84.toFixed(6))+","+String(lttd84.toFixed(6));
  539. _self.endText = item.inteName;
  540. }
  541. },
  542. startFocusHandler(evt){
  543. var _self = this;
  544. console.log('开始 标记');
  545. _self.currentFocus = 'start';
  546. getMyBiaoJi(_self.userId,'','','',1,1000).then((res)=>{
  547. if(res.success){
  548. console.log('biaoji')
  549. _self.tableResultData = res.data.list;
  550. _self.showPoiList = false;//关闭poi
  551. _self.showBiaoJiPanel = true;//打开标记
  552. _self.showStepPanel = false;//关闭详情路线
  553. }
  554. });
  555. },
  556. endFocusHandler(evt){
  557. var _self = this;
  558. console.log(evt);
  559. _self.currentFocus = 'end';
  560. getMyBiaoJi(_self.userId,'','','',1,1000).then((res)=>{
  561. if(res.success){
  562. console.log('biaoji')
  563. _self.tableResultData = res.data.list;
  564. _self.showPoiList = false;//关闭poi
  565. _self.showBiaoJiPanel = true;//打开标记
  566. _self.showStepPanel = false;//关闭详情路线
  567. }
  568. });
  569. },
  570. chooseTraffic(val){//选择交通工具
  571. this.showDaoHanButton = val;
  572. },
  573. startChangeEndHandler(){
  574. var str = this.startText;
  575. this.startText = this.endText;
  576. this.endText = str;
  577. var str1 = this.currentStartLocation;
  578. this.currentStartLocation = this.currentEndLocation;
  579. this.currentEndLocation = str1;
  580. },
  581. mapToolHandler:function(item){
  582. this.$emit("mapToolHandler",item);
  583. },
  584. showToolPanelHandler(){
  585. this.showToolPanel = !this.showToolPanel;
  586. },
  587. showPanel:function(){
  588. this.showXzqPanel = !this.showXzqPanel;
  589. },
  590. getAdData:function(){
  591. var _self = this;
  592. getAdData(_self.currentAdCode).then((response)=>{
  593. _self.nextLevelXzq = response.data;
  594. });
  595. },
  596. backToStep:function(item){
  597. this.currentStatus={
  598. currentType:item.type,
  599. currentTitle:item.title,
  600. currentCode:item.code,
  601. };
  602. var arr = [];
  603. for(var i=0;i<this.naviStateStack.length;i++){
  604. if(this.naviStateStack[i].code == item.code){
  605. for(var j=0;j<=i;j++){
  606. arr.push(this.naviStateStack[j]);
  607. }
  608. this.naviStateStack = arr;
  609. }
  610. }
  611. this.currentAdCode = item.code;
  612. this.getAdData();
  613. this.$emit("clickAd",{'adCode':item.code,"adName":item.title,"adGrad":item.adGrad});
  614. },
  615. closeNavigationPanel:function(item){
  616. this.showXzqPanel = false;
  617. },
  618. clickAd:function(item){
  619. this.currentStatus={
  620. currentType:'xzq',
  621. currentTitle:item.adName,
  622. currentCode:item.adCode,
  623. currentAdGrad:item.adGrad
  624. };
  625. this.naviStateStack.push({
  626. title:item.adName,
  627. type:'xzq',
  628. code:item.adCode,
  629. adGrad:item.adGrad
  630. });
  631. this.currentAdCode = item.adCode;
  632. this.getAdData();
  633. this.$emit("clickAd",item);
  634. // this.showXzqPanel = false;
  635. },
  636. click:function(item){
  637. var _self = this;
  638. _self.showToolPanel = false;
  639. _self.$emit('rightMenuClick',item);//点击之后 关闭
  640. if(item == "fullExtent"){
  641. _self.viewObject.extent = _self.fullExtent1;
  642. }else if(item == "clear"){
  643. _self.draw.reset();
  644. _self.measureLengthGraphicLayer_lable = _self.mapObject.findLayerById("measureLengthGraphicLayer_lable");
  645. if(_self.measureLengthGraphicLayer_lable){
  646. _self.mapObject.remove(_self.measureLengthGraphicLayer_lable);
  647. }
  648. _self.measureGraphicLayer = _self.mapObject.findLayerById("measureGraphicLayer");
  649. if(_self.measureGraphicLayer){
  650. _self.mapObject.remove(_self.measureGraphicLayer);
  651. }
  652. }else if(item == "measureDistance"){
  653. _self.measureDistance();
  654. }else if(item == "measureArea"){
  655. _self.measureArea();
  656. }else if(item == "biaoji"){
  657. _self.bjHandler();
  658. }else if(item == "daohang"){
  659. _self.showDaoHangPanel = !_self.showDaoHangPanel;
  660. if(!_self.showDaoHangPanel){
  661. _self.showStepPanel = false;
  662. var daohangGraphicLayer = _self.mapObject.findLayerById("daohangGraphicLayer");
  663. daohangGraphicLayer.removeAll();
  664. daohangGraphicLayer.visible = false;
  665. var daohangGraphicLayer1 = _self.mapObject.findLayerById("daohangGraphicLayer1");
  666. daohangGraphicLayer1.removeAll();
  667. daohangGraphicLayer1.visible = false;
  668. }
  669. }
  670. },
  671. bjHandler(){
  672. var _self = this;
  673. this.$emit('bjHandler');
  674. document.getElementById("mapNode").style.cursor = "crosshair";
  675. // document.getElementById("mapNode").style.cursor = "default";
  676. },
  677. measureDistance:function(){
  678. var _self = this;
  679. esriLoader.loadModules(["esri/views/2d/draw/Draw","esri/geometry/SpatialReference",
  680. "esri/geometry/Point","esri/layers/GraphicsLayer","dojo/domReady!"],options).then((
  681. [Draw,SpatialReference,Point,GraphicsLayer]) => {
  682. _self.measureGraphicLayer = _self.mapObject.findLayerById("measureGraphicLayer");
  683. if(_self.measureGraphicLayer){
  684. _self.measureGraphicLayer.removeAll();
  685. }else{
  686. _self.measureGraphicLayer = new GraphicsLayer({id:'measureGraphicLayer'});
  687. _self.mapObject.add(_self.measureGraphicLayer);
  688. }
  689. //标注 graphicLayer
  690. _self.measureLengthGraphicLayer_lable = _self.mapObject.findLayerById("measureLengthGraphicLayer_lable");
  691. if(_self.measureLengthGraphicLayer_lable){
  692. _self.measureLengthGraphicLayer_lable.removeAll();
  693. }else{
  694. _self.measureLengthGraphicLayer_lable = new GraphicsLayer({id:'measureLengthGraphicLayer_lable'});
  695. _self.mapObject.add(_self.measureLengthGraphicLayer_lable);
  696. }
  697. _self.draw = new Draw({
  698. view:_self.viewObject
  699. });
  700. var action = _self.draw.create("polyline", {mode: "click"});
  701. action.on("vertex-add", _self.measurePolyline_add);
  702. action.on("vertex-remove", _self.measurePolyline);
  703. action.on("cursor-update", _self.measurePolyline);
  704. action.on("draw-complete", _self.measurePolyline);
  705. }).catch(err => {
  706. console.error(err);
  707. });
  708. },
  709. measurePolyline:function(evt){
  710. var _self = this;
  711. esriLoader.loadModules(["esri/Graphic","esri/views/2d/draw/Draw","esri/geometry/SpatialReference",
  712. "esri/geometry/Polyline","esri/layers/GraphicsLayer","esri/geometry/geometryEngine",
  713. "esri/geometry/Point","dojo/domReady!"],options).then((
  714. [Graphic,Draw,SpatialReference,Polyline,GraphicsLayer,geometryEngine,Point]) => {
  715. _self.measureGraphicLayer.removeAll();
  716. var vertices = evt.vertices;
  717. var polyline = new Polyline({
  718. paths: vertices,
  719. spatialReference: 102100
  720. });
  721. var gra = new Graphic({
  722. geometry: polyline,
  723. symbol: {
  724. type: "simple-line", // autocasts as new SimpleLineSymbol()
  725. color: [255, 0, 0,0.7],
  726. width: "2px",
  727. }
  728. });
  729. _self.measureGraphicLayer.add(gra);
  730. var length = geometryEngine.geodesicLength(polyline,"kilometers");
  731. var x = vertices[vertices.length-1][0];
  732. var y = vertices[vertices.length-1][1];
  733. var pt = new Point({
  734. x:x,
  735. y:y,
  736. spatialReference:102100
  737. });
  738. var graLenght = new Graphic({
  739. geometry: pt,
  740. symbol: {
  741. type: "text",
  742. color: "yellow",
  743. haloColor: "black",
  744. haloSize: "1px",
  745. text: length.toFixed(2) + "公里",
  746. xoffset: 3,
  747. yoffset: 3,
  748. font: { // autocast as Font
  749. size: 14,
  750. family: "sans-serif"
  751. }
  752. }
  753. });
  754. _self.measureGraphicLayer.add(graLenght);
  755. }).catch(err => {
  756. console.error(err);
  757. });
  758. },
  759. //在每一个折点添加标注,不然会被remove掉
  760. measurePolyline_add:function(evt){
  761. var _self = this;
  762. esriLoader.loadModules(["esri/Graphic","esri/views/2d/draw/Draw","esri/geometry/SpatialReference",
  763. "esri/geometry/Polyline","esri/layers/GraphicsLayer","esri/geometry/geometryEngine",
  764. "esri/geometry/Point","dojo/domReady!"],options).then((
  765. [Graphic,Draw,SpatialReference,Polyline,GraphicsLayer,geometryEngine,Point]) => {
  766. _self.measureGraphicLayer.removeAll();
  767. var vertices = evt.vertices;
  768. var polyline = new Polyline({
  769. paths: vertices,
  770. spatialReference: 102100
  771. });
  772. var gra = new Graphic({
  773. geometry: polyline,
  774. symbol: {
  775. type: "simple-line", // autocasts as new SimpleLineSymbol()
  776. color: [255, 0, 0,0.7],
  777. width: "2px",
  778. }
  779. });
  780. _self.measureGraphicLayer.add(gra);
  781. var length = geometryEngine.geodesicLength(polyline,"kilometers");
  782. var x = vertices[vertices.length-1][0];
  783. var y = vertices[vertices.length-1][1];
  784. var pt = new Point({
  785. x:x,
  786. y:y,
  787. spatialReference:102100
  788. });
  789. var graLenght = new Graphic({
  790. geometry: pt,
  791. symbol: {
  792. type: "text",
  793. color: "yellow",
  794. haloColor: "black",
  795. haloSize: "1px",
  796. text: length.toFixed(2) + "公里",
  797. xoffset: 3,
  798. yoffset: 3,
  799. font: { // autocast as Font
  800. size: 14,
  801. family: "sans-serif"
  802. }
  803. }
  804. });
  805. _self.measureLengthGraphicLayer_lable.add(graLenght);
  806. }).catch(err => {
  807. console.error(err);
  808. });
  809. },
  810. measureArea:function(){
  811. var _self = this;
  812. esriLoader.loadModules(["esri/views/2d/draw/Draw","esri/geometry/SpatialReference",
  813. "esri/geometry/Point","esri/layers/GraphicsLayer","dojo/domReady!"],options).then((
  814. [Draw,SpatialReference,Point,GraphicsLayer]) => {
  815. _self.measureLengthGraphicLayer_lable = _self.mapObject.findLayerById("measureLengthGraphicLayer_lable");
  816. if(_self.measureLengthGraphicLayer_lable){
  817. _self.mapObject.remove(_self.measureLengthGraphicLayer_lable);
  818. }
  819. _self.measureGraphicLayer = _self.mapObject.findLayerById("measureGraphicLayer");
  820. if(_self.measureGraphicLayer){
  821. _self.measureGraphicLayer.removeAll();
  822. }else{
  823. _self.measureGraphicLayer = new GraphicsLayer({id:'measureGraphicLayer'});
  824. _self.mapObject.add(_self.measureGraphicLayer);
  825. }
  826. _self.draw = new Draw({
  827. view:_self.viewObject
  828. });
  829. var action = _self.draw.create("polygon", {mode: "click"});
  830. action.on("vertex-add", _self.measurePolygon);
  831. action.on("vertex-remove", _self.measurePolygon);
  832. action.on("cursor-update", _self.measurePolygon);
  833. action.on("draw-complete", _self.measurePolygon);
  834. }).catch(err => {
  835. console.error(err);
  836. });
  837. },
  838. measurePolygon:function(evt){
  839. var _self = this;
  840. esriLoader.loadModules(["esri/Graphic","esri/views/2d/draw/Draw","esri/geometry/SpatialReference",
  841. "esri/geometry/Polygon","esri/layers/GraphicsLayer","esri/geometry/geometryEngine",
  842. "dojo/domReady!"],options).then((
  843. [Graphic,Draw,SpatialReference,Polygon,GraphicsLayer,geometryEngine]) => {
  844. _self.measureGraphicLayer.removeAll();
  845. var vertices = evt.vertices;
  846. var polygon = new Polygon({
  847. rings: vertices,
  848. spatialReference: 102100
  849. });
  850. var gra = new Graphic({
  851. geometry: polygon,
  852. symbol: {
  853. type: "simple-fill", // autocasts as SimpleFillSymbol
  854. color: [140, 140, 222, 0.2],
  855. style: "solid",
  856. outline: { // autocasts as SimpleLineSymbol
  857. color: [255, 0, 0,0.7],
  858. width: 1
  859. }
  860. }
  861. });
  862. _self.measureGraphicLayer.add(gra);
  863. var area = geometryEngine.geodesicArea(polygon,"square-kilometers");
  864. if(area < 0){
  865. var simplifiedPolygon = geometryEngine.simplify(polygon);
  866. if (simplifiedPolygon) {
  867. area = geometryEngine.geodesicArea(simplifiedPolygon, "square-kilometers");
  868. }
  869. }
  870. var graArea = new Graphic({
  871. geometry: polygon.centroid,
  872. symbol: {
  873. type: "text",
  874. color: "yellow",
  875. haloColor: "black",
  876. haloSize: "1px",
  877. text: area.toFixed(2) + " 平方公里",
  878. xoffset: 3,
  879. yoffset: 3,
  880. font: { // autocast as Font
  881. size: 14,
  882. family: "sans-serif"
  883. }
  884. }
  885. });
  886. _self.measureGraphicLayer.add(graArea);
  887. }).catch(err => {
  888. console.error(err);
  889. });
  890. },
  891. }
  892. }
  893. </script>
  894. <style>
  895. #mapToolBarContainer_hhjc{
  896. position: fixed;
  897. top: 106px;
  898. right: 0px;
  899. }
  900. #mapTopToolBar{
  901. display: flex;
  902. background-color: white;
  903. height: 29px;
  904. border-radius: 3px;
  905. width: 200px;
  906. z-index: 1;
  907. }
  908. .xzqPanelClass{
  909. margin-top: 5px;
  910. background-color: white;
  911. width: 380px;
  912. margin-right: 10px;
  913. }
  914. .naviClickableLink{
  915. padding: 5px;
  916. padding-left: 10px;
  917. /* margin: 3px !important; */
  918. text-align: center;
  919. font-size: small;
  920. color: #000000b0;
  921. font-weight: normal;
  922. cursor: pointer;
  923. }
  924. .naviClickableLink:hover{
  925. text-decoration: underline;
  926. }
  927. .imgClass{
  928. width:17px;
  929. height: 17px;
  930. margin-right:5px;
  931. cursor:pointer;
  932. }
  933. .imgClass:hover{
  934. background-color: rgb(200,200,200);
  935. }
  936. .mapRightMenu{
  937. background-color: white;
  938. padding-left: 0px;
  939. /* padding-left:10px;
  940. padding-right:10px;
  941. padding-bottom:5px;
  942. padding-top:5px; */
  943. border: 1px solid rgba(142, 142, 142, 0.3);
  944. box-shadow: rgba(0, 0, 0, 0.23) 4px 3px 3px 0px;
  945. }
  946. .mapRightMenu .menuItem{
  947. padding: 10px;
  948. border-bottom: 1px solid rgba(154, 154, 154, 0.36);
  949. display: flex;
  950. flex-direction: row;
  951. justify-content: flex-start;
  952. align-items: center;
  953. }
  954. .mapRightMenu .menuItem:hover{
  955. cursor: pointer;
  956. background-color: rgba(154, 154, 154, 0.082);
  957. }
  958. .mapRightMenu:last-child{
  959. border-bottom:0px solid rgba(102, 102, 102, 0.507) !important;
  960. }
  961. ul.tabs.dir_tab {
  962. padding-top: 10px;
  963. width: 200px;
  964. border: 0;
  965. border-radius: 0;
  966. background: none;
  967. height: 30px;
  968. margin: 0 auto;
  969. white-space: nowrap;
  970. }
  971. ul.tabs.dir_tab li {
  972. height: 30px;
  973. width: 33.3333%;
  974. line-height: 30px;
  975. position: relative;
  976. display: block;
  977. float: left;
  978. text-align: center;
  979. margin: 0;
  980. text-transform: uppercase;
  981. letter-spacing: .8px;
  982. }
  983. ul.tabs.dir_tab li:active {
  984. background-color:#dbdbe7;
  985. }
  986. .trafficActivity{
  987. background-color: #dbdbe7;
  988. }
  989. .daohangContainerClass{
  990. height: 170px;
  991. background-color: #0069d5;
  992. right: 20px;
  993. position: fixed;
  994. width: 320px;
  995. }
  996. .poiClass{
  997. background-color: #ffffff;
  998. position: fixed;
  999. top: 310px;
  1000. right: 20px;
  1001. width: 320px;
  1002. max-height: 350px;
  1003. overflow: auto;
  1004. }
  1005. .poiClass :hover{
  1006. background: #ece9e9;
  1007. cursor:pointer;
  1008. }
  1009. .poiListClass{
  1010. padding: 5px;
  1011. padding-left: 15px;
  1012. }
  1013. .stepClass{
  1014. position: fixed;
  1015. top: 310px;
  1016. right: 20px;
  1017. width: 320px;
  1018. max-height: 350px;
  1019. background: #f4f9fd;
  1020. overflow: auto;
  1021. min-height: 70px;
  1022. }
  1023. .stepClass .el-collapse-item__header{
  1024. color:blue;
  1025. }
  1026. </style>