qinhouyu 8 ماه پیش
والد
کامیت
a84a677a2d
1فایلهای تغییر یافته به همراه18 افزوده شده و 13 حذف شده
  1. 18 13
      screen-demo/src/views/templateInstance.vue

+ 18 - 13
screen-demo/src/views/templateInstance.vue

@@ -337,35 +337,40 @@ export default {
 
     },
     setValue(){
-      if (this.start){
-        this.end = this.input3
-      }else {
-        this.start = this.input3
-      }
+      // if (this.start){
+      //   this.end = this.input3
+      // }else {
+      //   this.start = this.input3
+      // }
     },
     loadFind(){
-      let start = [125,43]
-      let end = [125.8,43.8]
       let option = {
         width: '8',
         color: '#f40'
       };
-      let toolRoute = new CTMapOl.extend.ToolRoute(this.map.map, option);
-      toolRoute.route(start, end).then(data => {
-        toolRoute.drawPath(data.routs)
-      })
       const location = new CTMapOl.extend.ToolLocation(this.map.map, {
         onPick: coords => {
-          console.log(coords)
+          console.log('coords',coords)
+          if (this.start){
+            this.end = [coords[0],coords[1]]
+          }else {
+            this.start = [coords[0],coords[1]]
+          }
         }
       })
       location._draw.overlay_.setStyle(null) //
-      location.locate([116.4, 39.6]) //
       location.pick() //
       const onClickMap = this.map.on('click', evt => {
         console.log(evt.coordinate)
       })
       CTMapOl.Observable.unByKey(onClickMap)
+
+      if (this.start.length===2 && this.end.length===2) {
+        let toolRoute = new CTMapOl.extend.ToolRoute(this.map.map, option);
+        toolRoute.route(this.start, this.end).then(data => {
+          toolRoute.drawPath(data.routs)
+        })
+      }
     },
     handleSizeChange(val) {
       console.log(`每页 ${val} 条`);