Commit 29a41770 by zhangxw

移动marker bug修改

1 parent 9f91db55
......@@ -45,13 +45,15 @@ Page({
refresh() {
this.isLoading = true
this.setData({
markers: [],
carInfoWindowObj: {}, // 当前点击的marker数据
carInfoArr: [], // 车辆marker数据
isShowCarInfoWindow: false, // 信息窗体
includePoints: [],
markers: []
includePoints: []
})
setTimeout(() => {
this.getData()
})
this.getData()
},
// 获取定位
locationCallback(e) {
......@@ -74,9 +76,6 @@ Page({
this.getVehicleData()
},
getVehicleData(){
this.setData({
isLoading: false
})
if(this.data.sns){
this.setData({
isLoading: true
......@@ -95,25 +94,30 @@ Page({
id: Number(item.sn), // 设备号唯一 可作为markerid
width: 28,
height: 36,
latitude: (this.data.carInfoWindowObj['type'] && Number(this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elat)) || Number(item['gpsLocation'].elat), // 默认显示GPS定位位置
longitude: (this.data.carInfoWindowObj['type'] && Number(this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elng)) || Number(item['gpsLocation'].elng),
// latitude: (this.data.carInfoWindowObj['type'] && Number(this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elat)) || Number(item['gpsLocation'].elat), // 默认显示GPS定位位置
// longitude: (this.data.carInfoWindowObj['type'] && Number(this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elng)) || Number(item['gpsLocation'].elng),
latitude: Number(item['gpsLocation'].elat), // 默认显示GPS定位位置
longitude: Number(item['gpsLocation'].elng),
iconPath: item.source === 1 ? '../../images/oncar.png' : '../../images/offcar.png'
})
includePoints.push({
latitude: (this.data.carInfoWindowObj['type'] && this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elat) || item['gpsLocation'].elat,
longitude: (this.data.carInfoWindowObj['type'] && this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elng) || item['gpsLocation'].elng,
// latitude: (this.data.carInfoWindowObj['type'] && this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elat) || item['gpsLocation'].elat,
// longitude: (this.data.carInfoWindowObj['type'] && this.data.carInfoWindowObj[this.data.carInfoWindowObj['type']].elng) || item['gpsLocation'].elng,
latitude: item['gpsLocation'].elat,
longitude: item['gpsLocation'].elng
})
item.type = this.data.carInfoWindowObj['type'] || 'gpsLocation' // 默认显示GPS的定位类型
// item.type = this.data.carInfoWindowObj['type'] || 'gpsLocation'
item.type = 'gpsLocation' // 默认显示GPS的定位类型
})
this.myMap.getMapCtx().includePoints({
points: includePoints,
padding: [60, 60, 60, 60]
})
this.setData({
carInfoArr: res.data,
includePoints: includePoints,
markers: markers
})
this.myMap.getMapCtx().includePoints({
points: includePoints,
padding: [60, 60, 60, 60]
})
} else {
wx.showModal({
content: '暂无数据',
......@@ -166,6 +170,7 @@ Page({
let data = JSON.parse(JSON.stringify(this.data.carInfoWindowObj))
let carInfoArr = JSON.parse(JSON.stringify(this.data.carInfoArr))
let includePoints = JSON.parse(JSON.stringify(this.data.includePoints))
let markers = this.data.markers
switch(Number(e.currentTarget.dataset.num)) {
case 1: // GPS
if (data['type'] === 'gpsLocation') return
......@@ -174,20 +179,28 @@ Page({
latitude: Number(this.data.carInfoWindowObj['gpsLocation'].elat),
longitude: Number(this.data.carInfoWindowObj['gpsLocation'].elng)
})
this.setData({
includePoints: includePoints
})
this.myMap.getMapCtx().translateMarker({
markerId: Number(this.data.carInfoWindowObj.sn),
destination: {
longitude: Number(this.data.carInfoWindowObj['gpsLocation'].elng),
latitude: Number(this.data.carInfoWindowObj['gpsLocation'].elat),
},
duration: 100,
animationEnd: () => {
this.moveToLocation(Number(this.data.carInfoWindowObj['gpsLocation'].elat), Number(this.data.carInfoWindowObj['gpsLocation'].elng))
markers.forEach(val => {
if (val.id === Number(this.data.carInfoWindowObj.sn)){
val.latitude = Number(this.data.carInfoWindowObj['gpsLocation'].elat)
val.longitude = Number(this.data.carInfoWindowObj['gpsLocation'].elng)
}
})
this.setData({
includePoints: includePoints,
markers: markers
})
this.moveToLocation(Number(this.data.carInfoWindowObj['gpsLocation'].elat), Number(this.data.carInfoWindowObj['gpsLocation'].elng))
// this.myMap.getMapCtx().translateMarker({ // 移动marker 在刷新后marker会不移动 小程序api有问题 后续再看看
// markerId: Number(this.data.carInfoWindowObj.sn),
// destination: {
// longitude: Number(this.data.carInfoWindowObj['gpsLocation'].elng),
// latitude: Number(this.data.carInfoWindowObj['gpsLocation'].elat),
// },
// duration: 100,
// animationEnd: () => {
// this.moveToLocation(Number(this.data.carInfoWindowObj['gpsLocation'].elat), Number(this.data.carInfoWindowObj['gpsLocation'].elng))
// }
// })
carInfoArr.forEach(val => {
if (val.id === this.data.carInfoWindowObj.id) {
val.type = 'gpsLocation'
......@@ -208,15 +221,21 @@ Page({
this.setData({
includePoints: includePoints
})
this.myMap.getMapCtx().translateMarker({
markerId: Number(this.data.carInfoWindowObj.sn),
destination: {
longitude: Number(this.data.carInfoWindowObj['bsLocation'].elng),
latitude: Number(this.data.carInfoWindowObj['bsLocation'].elat),
},
duration: 100,
animationEnd: () => {
this.moveToLocation(Number(this.data.carInfoWindowObj['bsLocation'].elat), Number(this.data.carInfoWindowObj['bsLocation'].elng))
// this.myMap.getMapCtx().translateMarker({
// markerId: Number(this.data.carInfoWindowObj.sn),
// destination: {
// longitude: Number(this.data.carInfoWindowObj['bsLocation'].elng),
// latitude: Number(this.data.carInfoWindowObj['bsLocation'].elat),
// },
// duration: 100,
// animationEnd: () => {
// this.moveToLocation(Number(this.data.carInfoWindowObj['bsLocation'].elat), Number(this.data.carInfoWindowObj['bsLocation'].elng))
// }
// })
markers.forEach(val => {
if (val.id === Number(this.data.carInfoWindowObj.sn)){
val.latitude = Number(this.data.carInfoWindowObj['bsLocation'].elat)
val.longitude = Number(this.data.carInfoWindowObj['bsLocation'].elng)
}
})
carInfoArr.forEach(val => {
......@@ -226,8 +245,11 @@ Page({
})
this.setData({
carInfoWindowObj: data,
carInfoArr: carInfoArr
carInfoArr: carInfoArr,
includePoints: includePoints,
markers: markers
})
this.moveToLocation(Number(this.data.carInfoWindowObj['bsLocation'].elat), Number(this.data.carInfoWindowObj['bsLocation'].elng))
if (this.data.carInfoWindowObj['bsLocation'].transferAddress) return
wx.request({
url: `https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`+ this.data.carInfoWindowObj['bsLocation'].elat + ',' + this.data.carInfoWindowObj['bsLocation'].elng,
......@@ -267,6 +289,9 @@ Page({
var lng,lat;
lng = this.data.carInfoWindowObj['gpsLocation'].elng
lat = this.data.carInfoWindowObj['gpsLocation'].elat
this.setData({
isUpdate: false
})
wx.navigateTo({ // 车辆追踪gps定位坐标
url: `../../pages/newCarTrace/carTrace?lat=${lat}&lng=${lng}`
})
......@@ -288,6 +313,9 @@ Page({
},
// 轨迹回放
traReplay(e) {
this.setData({
isUpdate: false
})
wx.navigateTo({
url: `../../pages/newTraReplay/traReplay?sn=${encodeURIComponent(this.data.carInfoWindowObj.encryptSn)}&locationType=${this.data.carInfoWindowObj.type}`
});
......@@ -309,6 +337,9 @@ Page({
},
// 实时监控
monitor() {
this.setData({
isUpdate: false
})
wx.navigateTo({
url: `../../pages/newMonitor/monitor?sn=${encodeURIComponent(this.data.carInfoWindowObj.encryptSn)}`
});
......
const util = require('../../utils/util.js');
const WXRequest = require('../../utils/wxrequest.js');
const moment = require('../../utils/moment.min.js');
Page({
......@@ -34,7 +33,8 @@ Page({
selectTime: '',
sn: null,
type: null,
durationArr: [20000, 15000, 10000, 5000]
durationArr: [20000, 15000, 10000, 5000],
optTime: moment().format('YYYY-MM-DD')
},
/**
......
......@@ -39,10 +39,7 @@
mode="date"
end="{{optTime}}"
class="tabbar-item"
bindchange="dateChange"
value="{{speedItemsIndex}}"
range="{{speedItems}}"
range-key="label">
bindchange="dateChange">
<button size="mini" class="date-class">{{selectTime}}</button>
</picker>
</view>
......
......@@ -109,7 +109,7 @@
.time-pick .tabbar-item .date-class{
width: 100%;
height: 50rpx;
vertical-align: middle;
line-height: 50rpx;
}
.time-choose .weui-flex__item {
padding: 0 6rpx;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!