mapTest.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. <template>
  2. <div class="container">
  3. <div id="amap-container"></div>
  4. <div class="mapcontroller">
  5. <div class="in_transit_information">
  6. <label class="item_details">起点:{{ startPointName }}</label>
  7. <br />
  8. <label class="item_details">收货地址:{{ endPointName }}</label>
  9. <br />
  10. </div>
  11. <div class="driving_information2">
  12. <label class="item_details">时间:{{ runRoute.gtm }}</label>
  13. <br />
  14. <label class="item_details">车速:{{ runRoute.spd }}千米/小时</label>
  15. <br />
  16. <br />
  17. <!--控制条-->
  18. <div class="map-control" v-show="isActual">
  19. <!--播放暂停按钮-->
  20. <Icon
  21. v-if="!isPlay"
  22. class="play-icon play"
  23. type="ios-play"
  24. @click="
  25. isPlay = true
  26. play()
  27. navgControl(playIcon)
  28. "
  29. />
  30. <Icon
  31. v-else
  32. class="play-icon pause"
  33. type="ios-pause"
  34. @click="
  35. isPlay = false
  36. stop()
  37. navgControl('pause')
  38. "
  39. />
  40. <Icon class="play-icon quickly" type="ios-play" @click="addIndex()" />
  41. <!--已播放时间-->
  42. <!--进度条-->
  43. <div class="mySlider">
  44. <Slider
  45. class="map-slider"
  46. v-model="sliderVal"
  47. :tip-format="hideFormat"
  48. :step="0.0001"
  49. ></Slider>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <el-row>
  55. <el-button type="primary" @click="slow">慢速</el-button>
  56. <el-button type="success" @click="middle">中速</el-button>
  57. <el-button type="danger" @click="fast">快速</el-button>
  58. <el-button type="success" @click="addIndex" plain>快进</el-button>
  59. <el-button type="danger" @click="stop" plain>暂停</el-button>
  60. <el-button type="success" @click="play" plain>开始</el-button>
  61. <el-select
  62. style="width:100px"
  63. @change="changeParkingTime"
  64. v-model="parkingTime"
  65. placeholder="停车"
  66. >
  67. <el-option
  68. v-for="item in parkingOptions"
  69. :key="item.value"
  70. :label="item.label"
  71. :value="item.value"
  72. >
  73. </el-option>
  74. </el-select>
  75. <el-select
  76. style="width:100px"
  77. @change="changeLeaveTime"
  78. v-model="leaveTime"
  79. placeholder="离线"
  80. >
  81. <el-option
  82. v-for="item in parkingOptions"
  83. :key="item.value"
  84. :label="item.label"
  85. :value="item.value"
  86. >
  87. </el-option>
  88. </el-select>
  89. </el-row>
  90. <div class="btnx">
  91. <el-button type="primary" class="" @click="openInfo"
  92. >打开信息窗体</el-button
  93. >
  94. <el-button type="primary" class="" @click="closeinfo"
  95. >关闭信息窗口</el-button
  96. >
  97. </div>
  98. </div>
  99. </template>
  100. <script>
  101. import { shallowRef } from '@vue/reactivity'
  102. import { lazyAMapApiLoaderInstance } from 'vue-amap'
  103. import Slider from './slider.vue'
  104. Vue.use(Slider)
  105. import Vue from 'vue'
  106. var infoWindow
  107. export default {
  108. name: 'PathView',
  109. props: {
  110. orderNumber: '',
  111. capacityNumber: '',
  112. startPointName: '',
  113. endPointName: ''
  114. },
  115. setup() {
  116. const map = shallowRef(null)
  117. return {
  118. map
  119. }
  120. },
  121. watch: {
  122. //监听车牌号变化
  123. orderNumber: {
  124. deep: true,
  125. handler(val, oldVal) {
  126. console.log(val)
  127. this.initData(val)
  128. }
  129. }
  130. },
  131. data() {
  132. return {
  133. ///che
  134. isTimesChoose: false,
  135. isActual: true,
  136. isPlay: false,
  137. passedTime: '12:02:10',
  138. sliderVal: 0,
  139. times: 1,
  140. totalTime: '11',
  141. speed: 10000,
  142. startTime: '',
  143. endTime: '',
  144. //选择停车时长
  145. parkingTime: null,
  146. //停车时长选择区间
  147. parkingOptions: [
  148. {
  149. value: 600000,
  150. label: '10分钟'
  151. },
  152. {
  153. value: 1200000,
  154. label: '20分钟'
  155. },
  156. {
  157. value: 1800000,
  158. label: '30分钟'
  159. },
  160. {
  161. value: 2400000,
  162. label: '40分钟'
  163. },
  164. {
  165. value: 3000000,
  166. label: '50分钟'
  167. },
  168. {
  169. value: 3600000,
  170. label: '60分钟'
  171. },
  172. {
  173. value: 36000000,
  174. label: '关闭'
  175. }
  176. ],
  177. //离线图标
  178. leaveMark: [],
  179. //停车图标
  180. parkMark: [],
  181. //选择离线时长
  182. leaveTime: null,
  183. //离线时长选择区间
  184. leaveOptions: [
  185. {
  186. value: 600000,
  187. label: '10分钟'
  188. },
  189. {
  190. value: 1200000,
  191. label: '20分钟'
  192. },
  193. {
  194. value: 1800000,
  195. label: '30分钟'
  196. },
  197. {
  198. value: 2400000,
  199. label: '40分钟'
  200. },
  201. {
  202. value: 3000000,
  203. label: '50分钟'
  204. },
  205. {
  206. value: 3600000,
  207. label: '60分钟'
  208. },
  209. {
  210. value: 36000000,
  211. label: '关闭'
  212. }
  213. ],
  214. //已行驶轨迹
  215. runRoute: {
  216. agl: '',
  217. gtm: '',
  218. hgt: '',
  219. lat: '',
  220. lon: '',
  221. mil: '',
  222. spd: ''
  223. },
  224. point: '',
  225. pointNext: '',
  226. loading: null,
  227. navgtrSpeed: 1,
  228. //地图中心位置
  229. centerPoint: {
  230. pointLat: '',
  231. pointLon: ''
  232. },
  233. //自定义窗体信息
  234. ctmarkes: {
  235. lat: '33.015888071433764',
  236. lon: '115.96995235868168',
  237. title: '豫SE8888',
  238. details: '安徽省阜阳市颍东区阜阳舜岳水泥公司,西北方向,155.1米'
  239. },
  240. //运输详情
  241. transportDetail: {
  242. //车牌号
  243. capacityNumber: '',
  244. //规划路线
  245. estimateRoute: [
  246. {
  247. lat: '33.015888071433764',
  248. lon: '115.96995235868168'
  249. }
  250. ],
  251. //规划线路
  252. estimatePath: [[114.03046212985384, 32.49786984660489]],
  253. //已行驶轨迹
  254. runRoute: [
  255. {
  256. agl: '44',
  257. gtm: '2022年03月09日 16:47:24',
  258. hgt: '13',
  259. lat: '32.906411535084985',
  260. lon: '115.76177868692135',
  261. mil: '429409.2',
  262. spd: '17.0'
  263. }
  264. ],
  265. runPath: [[114.03922119568348, 32.49746162481379]],
  266. //当前位置
  267. currentPointName: '中国达州市通川区',
  268. //当前位置经纬度
  269. currentPoint: {
  270. lat: '',
  271. lon: ''
  272. },
  273. //起点位置
  274. startPointName: '中国达州市通川区',
  275. //起点位置经纬度
  276. startPoint: {
  277. lon: '114.03922119568348',
  278. lat: '32.49746162481379'
  279. },
  280. //终点位置
  281. endPointName: '中国成都萧山',
  282. //终点位置经纬度
  283. endPoint: {
  284. lon: '115.96995737755431',
  285. lat: '33.01595479752097'
  286. },
  287. //自定义标记
  288. content: [],
  289. //异常位置
  290. abnormalLocation: []
  291. },
  292. listPath: [],
  293. //组件
  294. pathSimplifierIns: {},
  295. pathNavigator: {},
  296. //地图解析
  297. geocoder: null,
  298. currentPointName: ''
  299. }
  300. },
  301. created() {
  302. let that = this
  303. that.initData(that.orderNumber)
  304. },
  305. mounted() {},
  306. methods: {
  307. //停车时间改变
  308. changeParkingTime() {
  309. let that = this
  310. //清除之前的停车点
  311. that.hideParkingMark()
  312. //计算时间的点
  313. let calculationPoint = null
  314. that.listPath[0].runRoute.forEach(function(item, indexOf) {
  315. if (indexOf + 1 < that.listPath[0].runRoute.length) {
  316. //判断calculationPoint是否为空,如果是空的说明当前没有在计算停车时间
  317. if (calculationPoint == null && item.spd == '0.0') {
  318. calculationPoint = item
  319. } else if (calculationPoint != null && item.spd != '0.0') {
  320. let beforeTime = that.stringToDate(calculationPoint.gtm)
  321. let item2 = that.listPath[0].runRoute[indexOf]
  322. let afterTime = that.stringToDate(item2.gtm)
  323. let second = afterTime - beforeTime
  324. if (second > that.parkingTime) {
  325. let message = '停车:' + second / 60000
  326. that.initParkingMarkes(
  327. 20,
  328. 35,
  329. require('@/assets/img/park.png'),
  330. calculationPoint.lon,
  331. calculationPoint.lat,
  332. message.split('.')[0] + '分钟'
  333. )
  334. }
  335. calculationPoint = null
  336. }
  337. }
  338. })
  339. },
  340. //字符串转为Date
  341. stringToDate(dateString) {
  342. console.log(dateString)
  343. let dateStr = dateString
  344. .replace('年', '-')
  345. .replace('月', '-')
  346. .replace('日', '')
  347. return Date.parse(dateStr)
  348. },
  349. //停车所有离线图标
  350. hideParkingMark() {
  351. let that = this
  352. that.parkMark.forEach(function(item, indexOf) {
  353. item.hide()
  354. })
  355. },
  356. //离线时间改变时获得超过时间的点信息
  357. changeLeaveTime() {
  358. let that = this
  359. //关闭所有图标
  360. that.hideLeaveMark()
  361. that.listPath[0].runRoute.forEach(function(item, indexOf) {
  362. if (indexOf + 1 < that.listPath[0].runRoute.length) {
  363. let beforeTime = that.stringToDate(item.gtm)
  364. let item2 = that.listPath[0].runRoute[indexOf + 1]
  365. let afterTime = that.stringToDate(item2.gtm)
  366. let second = afterTime - beforeTime
  367. if (second > that.leaveTime) {
  368. let message = '离线:' + second / 60000
  369. that.initLeaveMarkes(
  370. 20,
  371. 35,
  372. require('@/assets/img/leave.png'),
  373. item2.lon,
  374. item2.lat,
  375. message.split('.')[0] + '分钟'
  376. )
  377. }
  378. }
  379. })
  380. },
  381. //关闭所有离线图标
  382. hideLeaveMark() {
  383. let that = this
  384. that.leaveMark.forEach(function(item, indexOf) {
  385. item.hide()
  386. })
  387. },
  388. slow() {
  389. console.log('slow')
  390. let that = this
  391. that.pathNavigator.setSpeed(1000)
  392. },
  393. middle() {
  394. console.log('middle')
  395. let that = this
  396. that.pathNavigator.setSpeed(10000)
  397. },
  398. fast() {
  399. console.log('fast')
  400. let that = this
  401. that.pathNavigator.setSpeed(100000)
  402. },
  403. play() {
  404. let that = this
  405. that.pathNavigator.resume()
  406. },
  407. stop() {
  408. let that = this
  409. that.pathNavigator.pause()
  410. },
  411. addIndex() {
  412. let that = this
  413. let increment = that.listPath[0].runPath.length * 0.1
  414. let result = that.point + increment
  415. if(result < that.listPath[0].runPath.length){
  416. that.pathNavigator.start(that.point + increment)
  417. }else{
  418. that.pathNavigator.start(that.listPath[0].runPath.length-1)
  419. }
  420. },
  421. ///che
  422. navgControl() {},
  423. hideFormat(value) {
  424. let that = this
  425. that.sliderVal = value
  426. },
  427. initParkingMarkes(weight, height, image, lon, lat, title) {
  428. let that = this
  429. //图标标记点
  430. let pointicon = new AMap.Icon({
  431. size: new AMap.Size(weight, height), // 图标尺寸
  432. image: image, // Icon的图像
  433. imageOffset: new AMap.Pixel(0, 0), // 图像相对展示区域的偏移量,适于雪碧图等
  434. imageSize: new AMap.Size(weight, height) // 根据所设置的大小拉伸或压缩图片
  435. })
  436. // 创建一个 Marker 实例:
  437. var pointmarker = new AMap.Marker({
  438. position: new AMap.LngLat(lon, lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
  439. icon: pointicon,
  440. title: title
  441. })
  442. that.parkMark.push(pointmarker)
  443. // 将创建的点标记添加到已有的地图实例:
  444. that.map.add(pointmarker)
  445. },
  446. //创建离线和停车的标记
  447. initLeaveMarkes(weight, height, image, lon, lat, title) {
  448. let that = this
  449. //图标标记点
  450. let pointicon = new AMap.Icon({
  451. size: new AMap.Size(weight, height), // 图标尺寸
  452. image: image, // Icon的图像
  453. imageOffset: new AMap.Pixel(0, 0), // 图像相对展示区域的偏移量,适于雪碧图等
  454. imageSize: new AMap.Size(weight, height) // 根据所设置的大小拉伸或压缩图片
  455. })
  456. // 创建一个 Marker 实例:
  457. var pointmarker = new AMap.Marker({
  458. position: new AMap.LngLat(lon, lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
  459. icon: pointicon,
  460. title: title
  461. })
  462. that.leaveMark.push(pointmarker)
  463. // 将创建的点标记添加到已有的地图实例:
  464. that.map.add(pointmarker)
  465. },
  466. initData(orderNumber) {
  467. let that = this
  468. that.axios
  469. .post('/api/v1/otms/fullPath?orderNumber=' + orderNumber)
  470. .then(res => {
  471. console.log(res.data)
  472. if (res.data.data == '-1') {
  473. this.$message.error('运输订单未关闭的自提车辆无权查看!')
  474. } else if (res.data.data.startAndEndRoutes != null) {
  475. that.listPath = res.data.data.startAndEndRoutes
  476. that.startTime = res.data.data.startAndEndRoutes[0].runRoute[0].gtm
  477. that.endTime =
  478. res.data.data.startAndEndRoutes[0].runRoute[
  479. res.data.data.startAndEndRoutes[0].runRoute.length - 1
  480. ].gtm
  481. that.initMap()
  482. } else {
  483. that.listPath = []
  484. this.$message.error('车辆没有开启GPS')
  485. }
  486. })
  487. },
  488. endline() {
  489. let that = this
  490. that.initPolyline(that.listPath[0].estimatePath, '#FF0000')
  491. },
  492. //创建起点终点当前点
  493. threeMarker() {
  494. let that = this
  495. that.listPath.forEach((element, index) => {
  496. //开始标记点
  497. if (element.startPoint.lon != '' && element.startPoint.lat != '') {
  498. that.initMarkes(
  499. 20,
  500. 35,
  501. require('@/assets/img/start.png'),
  502. element.startPoint.lon,
  503. element.startPoint.lat,
  504. '起点'
  505. )
  506. }
  507. //当前点
  508. that.getCurrentPointName([
  509. element.runRoute[element.runRoute.length - 1].lon,
  510. element.runRoute[element.runRoute.length - 1].lat
  511. ])
  512. //结束标记点
  513. // if (element.endPoint.lon != '' && element.endPoint.lat != '') {
  514. // that.initMarkes(
  515. // 20,
  516. // 35,
  517. // require('@/assets/img/end.png'),
  518. // element.endPoint.lon,
  519. // element.endPoint.lat,
  520. // '终点'
  521. // )
  522. // }
  523. })
  524. },
  525. //获得结束地址
  526. getCurrentPointName(lnglatXY) {
  527. let that = this
  528. that.geocoder.getAddress(lnglatXY, function(status, result) {
  529. if (status === 'complete' && result.info === 'OK') {
  530. that.currentPointName = result.regeocode.formattedAddress
  531. that.initCustomMarkes(
  532. that.capacityNumber,
  533. '位置:' +
  534. that.currentPointName +
  535. '<br/>' +
  536. '距离:' +
  537. that.listPath[0].miled +
  538. '<br/>' +
  539. '时间范围:' +
  540. that.startTime +
  541. ' 至 ' +
  542. that.endTime,
  543. lnglatXY[0],
  544. lnglatXY[1]
  545. )
  546. }
  547. })
  548. },
  549. //defualt数据
  550. defaultDate() {
  551. // let that=this;
  552. // that.pathNavigator.start(that.listPath[0].runPath.length)
  553. // that.pathNavigator.pause();
  554. },
  555. //初始化地图
  556. initMap() {
  557. lazyAMapApiLoaderInstance.load().then(() => {
  558. let that = this
  559. that.map = new AMap.Map('amap-container', {
  560. //设置地图容器id
  561. viewMode: '2D', //是否为2D地图模式
  562. zoom: 10, //初始化地图级别
  563. center: [105.602725, 37.076636] //初始化地图中心点位置
  564. })
  565. that.initGeocoder()
  566. that.initPathSimplifier()
  567. that.threeMarker()
  568. //that.initCustomMarkes(that.capacityNumber+"("+that.listPath[0].miled+")",that.listPath[0].currentPointName,that.listPath[0].currentPoint.lon,that.listPath[0].currentPoint.lat)
  569. //that.endline()//预估路径
  570. })
  571. },
  572. initCustomMarkes(title, details, lon, lat) {
  573. let that = this
  574. //自定义窗体内容
  575. var content = [
  576. "<div style='top:1px;width: 200px; background-color: rgba(22, 160, 133, 1);' ><font color='white'>" +
  577. title +
  578. '</font>',
  579. "<div style='background-color:(22, 160, 133, 1); ;'><font color='white'>" +
  580. details +
  581. '</font></div></div>'
  582. ]
  583. // 创建 infoWindow 实例
  584. infoWindow = new AMap.InfoWindow({
  585. content: content.join('<br>') //传入 dom 对象,或者 html 字符串
  586. })
  587. // 打开信息窗体
  588. infoWindow.open(that.map, [lon, lat])
  589. },
  590. // 关闭信息窗口
  591. closeinfo() {
  592. infoWindow.close()
  593. },
  594. openInfo() {
  595. let lon = null
  596. let lat = null
  597. console.log(this.listPath)
  598. this.listPath.forEach(e => {
  599. if (e.endPoint != {} && e.endPoint != '' && e.endPoint != null) {
  600. lon = e.endPoint.lon
  601. lat = e.endPoint.lat
  602. } else {
  603. lon = e.runRoute[e.runRoute.length - 1].lon
  604. lat = e.runRoute[e.runRoute.length - 1].lat
  605. }
  606. })
  607. infoWindow.open(this.map, [lon, lat])
  608. },
  609. initPolyline(path, color) {
  610. let that = this
  611. //预计轨迹
  612. var endLine = new AMap.Polyline({
  613. map: that.map,
  614. path: path,
  615. isOutline: true,
  616. outlineColor: color,
  617. borderWeight: 0,
  618. strokeColor: '#FF0000',
  619. strokeOpacity: 1,
  620. strokeWeight: 5,
  621. // 折线样式还支持 'dashed'
  622. strokeStyle: 'solid',
  623. // strokeStyle是dashed时有效
  624. strokeDasharray: [10, 5],
  625. lineJoin: 'round',
  626. lineCap: 'round',
  627. zIndex: 50
  628. })
  629. that.map.setFitView([[endLine]])
  630. },
  631. //创建简单的标记
  632. initMarkes(weight, height, image, lon, lat, title) {
  633. let that = this
  634. //图标标记点
  635. let pointicon = new AMap.Icon({
  636. size: new AMap.Size(weight, height), // 图标尺寸
  637. image: image, // Icon的图像
  638. imageOffset: new AMap.Pixel(0, 0), // 图像相对展示区域的偏移量,适于雪碧图等
  639. imageSize: new AMap.Size(weight, height) // 根据所设置的大小拉伸或压缩图片
  640. })
  641. // 创建一个 Marker 实例:
  642. var pointmarker = new AMap.Marker({
  643. position: new AMap.LngLat(lon, lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
  644. icon: pointicon,
  645. title: title
  646. })
  647. // 将创建的点标记添加到已有的地图实例:
  648. that.map.add(pointmarker)
  649. },
  650. //创建轨迹和巡航器
  651. initPathSimplifier() {
  652. let that = this
  653. // ...你的操作
  654. new AMapUI.load(['ui/misc/PathSimplifier'], PathSimplifier => {
  655. if (!PathSimplifier.supportCanvas) {
  656. alert('当前环境不支持 Canvas!')
  657. return
  658. }
  659. //创建轨迹和巡航器
  660. // 创建组件实例
  661. that.pathSimplifierIns = new PathSimplifier({
  662. map: that.map,
  663. zIndex: 100, // 图层叠加顺序
  664. data: that.listPath, // 巡航路径
  665. // 获取巡航路径中的路径坐标数组
  666. getPath: (pathData, pathIndex) => {
  667. return pathData.runPath
  668. },
  669. //鼠标悬浮停时显示消息
  670. getHoverTitle: function(pathData, pathIndex, pointIndex) {
  671. //返回鼠标悬停时显示的信息
  672. if (pointIndex >= 0) {
  673. if (pathData.runRoute[pointIndex].gtm !== 'undefined') {
  674. //鼠标悬停在某个轨迹节点上
  675. return (
  676. pathData.runRoute[pointIndex].gtm +
  677. ',速度' +
  678. pathData.runRoute[pointIndex].spd +
  679. '千米/小时'
  680. )
  681. }
  682. }
  683. },
  684. //设置轨迹样式
  685. renderOptions: {
  686. //轨迹线的样式
  687. pathLineStyle: {
  688. strokeStyle: 'black',
  689. lineWidth: 6,
  690. dirArrowStyle: true
  691. }
  692. }
  693. })
  694. // 创建巡航器
  695. that.pathNavigator = that.pathSimplifierIns.createPathNavigator(0, {
  696. loop: false, // 是否循环
  697. speed: that.speed, // 速度(km/h)
  698. pathNavigatorStyle: {
  699. width: 20,
  700. height: 40,
  701. content: PathSimplifier.Render.Canvas.getImageContent(
  702. require('@/assets/img/smallcar.png'),
  703. onload,
  704. onerror
  705. ),
  706. strokeStyle: null,
  707. fillStyle: null
  708. }
  709. })
  710. //开启巡航
  711. that.pathNavigator.start()
  712. that.defaultDate()
  713. //开始事件
  714. that.pathNavigator.on('start resume', function() {
  715. // that.navgtr._startTime = Date.now();
  716. // that.navgtr._startDist = this.getMovedDistance();
  717. })
  718. //暂停
  719. that.pathNavigator.on('stop pause', function() {
  720. // that.navgtr._movedTime = Date.now() - that.navgtr._startTime;
  721. // that.navgtr._movedDist = this.getMovedDistance() - that.navgtr._startDist;
  722. })
  723. that.pathNavigator.on('move', function(data, value) {
  724. that.updateLable(value)
  725. })
  726. })
  727. },
  728. updateLable(value) {
  729. let that = this
  730. that.point = value.dataItem.pointIndex
  731. that.runRoute = value.dataItem.pathData.runRoute[that.point]
  732. that.sliderVal =
  733. (value.dataItem.pointIndex / value.dataItem.pathData.runRoute.length) *
  734. 100
  735. },
  736. changeSpeed(value) {
  737. // console.log(value)
  738. // let that=this;
  739. // that.times=value;
  740. },
  741. playIcon() {
  742. console.log('nihoa')
  743. },
  744. //逆解码函数
  745. initGeocoder() {
  746. let that = this
  747. console.log('initGeocoder')
  748. AMap.plugin('AMap.Geocoder', function() {
  749. that.geocoder = new AMap.Geocoder({
  750. radius: 1000,
  751. extensions: 'all'
  752. })
  753. console.log(that.geocoder)
  754. })
  755. }
  756. }
  757. }
  758. </script>
  759. <style>
  760. .mapcontroller {
  761. width: 250px;
  762. height: 260px;
  763. background: white;
  764. position: absolute;
  765. z-index: 99;
  766. top: 0;
  767. left: 0;
  768. }
  769. .container {
  770. width: 100%;
  771. height: 100%;
  772. }
  773. .item_details {
  774. display: block;
  775. margin-top: 20px;
  776. position: relative;
  777. left: 30px;
  778. width: 200px;
  779. height: 0px;
  780. }
  781. #amap-container {
  782. position: relative;
  783. width: 100%;
  784. height: 100%;
  785. overflow: hidden;
  786. margin: 0;
  787. font-family: '微软雅黑';
  788. }
  789. .driving_information2 {
  790. position: relative;
  791. top: 70px;
  792. }
  793. .driving_information3 {
  794. position: absolute;
  795. z-index: 99;
  796. top: 0;
  797. left: 0;
  798. position: relative;
  799. top: 50px;
  800. }
  801. /* 进度条 */
  802. .mySlider {
  803. width: 150px;
  804. height: 20px;
  805. display: inline-block;
  806. position: relative;
  807. left: 32px;
  808. }
  809. .play {
  810. position: relative;
  811. left: 28px;
  812. }
  813. .quickly {
  814. float: right;
  815. position: relative;
  816. left: -20px;
  817. top: 10px;
  818. }
  819. .pause {
  820. position: relative;
  821. left: 28px;
  822. }
  823. .passed-time {
  824. position: relative;
  825. left: 5px;
  826. }
  827. .end-time {
  828. position: relative;
  829. left: 5px;
  830. }
  831. .map-times {
  832. position: relative;
  833. background-color: red;
  834. width: 40px;
  835. }
  836. </style>
  837. <style lang="scss" scoped>
  838. .btnx {
  839. z-index: 1000;
  840. position: fixed;
  841. bottom: 10px;
  842. right: 10px;
  843. }
  844. </style>