Bladeren bron

更新 轨迹,marker逻辑

wzh 3 jaren geleden
bovenliggende
commit
7837f0d36f
1 gewijzigde bestanden met toevoegingen van 35 en 24 verwijderingen
  1. 35 24
      miniprogram/pages/voyages/detail/detail.js

+ 35 - 24
miniprogram/pages/voyages/detail/detail.js

@@ -24,8 +24,17 @@ Page({
       dottedLine: true,
       color: "#eb2f06"
     }],
-    markers: [],
-    pageSize: 20
+    markers: [{
+      id: 999,
+      latitude: '',
+      longitude: '',
+      iconPath: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/ship-red-icon.png",
+      height: 20,
+      width: 20
+    }],
+    pageSize: 20,
+    latitude: 31.891992,
+    longitude: 120.551369,
   },
   changeTab(e) {
     let {
@@ -48,37 +57,39 @@ Page({
       voyage,
       waybills
     } = res.data.result
+    if (coordinates.length) {
+      let points = []
+      for (let i of coordinates) {
+        points.push({
+          latitude: i.latitude,
+          longitude: i.longitude
+        })
+      }
+      let {
+        latitude,
+        longitude
+      } = points[points.length - 1]
+      this.data.latitude = latitude
+      this.data.longitude = longitude
+      this.data.markers[0].latitude = latitude
+      this.data.markers[0].longitude = longitude
+      this.data.polyline[0].points = points
 
-    let points = []
-    for (let i of coordinates) {
-      points.push({
-        latitude: i.latitude,
-        longitude: i.longitude
+      this.setData({
+        polyline: this.data.polyline,
+        markers: this.data.markers,
+        latitude: this.data.latitude,
+        longitude: this.data.longitude,
       })
+
     }
-    let {
-      latitude,
-      longitude
-    } = points[points.length - 1]
-    let markers = [{
-      id: 999,
-      latitude,
-      longitude,
-      iconPath: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/ship-red-icon.png",
-      height: 20,
-      width: 20
-    }]
-    this.data.polyline[0].points = points
+
     this.setData({
       coordinates,
       medias,
       policys,
       voyage,
       waybills,
-      polyline: this.data.polyline,
-      latitude,
-      longitude,
-      markers
     })
   },