Commit 29a41770 by zhangxw

移动marker bug修改

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