a9d60b70d3400054536711feb6749643fe96b2fa.svn-base 49 KB

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