定位页面开发

This commit is contained in:
binbin_pan 2024-07-03 20:05:33 +08:00
parent 6adb1dc728
commit d04f23454b
1 changed files with 33 additions and 79 deletions

View File

@ -45,14 +45,7 @@ export default {
equipmentNumber: 'H906L', //
engineering: '大禹治水', //
map: null,
centerPoint: [113.271431, 23.135336], //
animiationLineList: [], // 线
lineStyle: {
// 线
color: '#0e83ed',
width: 2,
opacity: 0.6,
},
//
linePointList: [
{
lng: 116.297611,
@ -82,24 +75,7 @@ export default {
lng: 116.307223,
lat: 40.056379,
},
], // 线
// map: {
// center: { lng: 113.763924, lat: 22.938634 },
// zoom: 18,
// show: true,
// dragging: true,
// },
// lineList: [
// { lng: 113.763924, lat: 22.938634 },
// { lng: 113.759621, lat: 22.933625 },
// { lng: 113.76654, lat: 22.934174 },
// { lng: 113.766558, lat: 22.932916 },
// { lng: 113.766558, lat: 22.932916 },
// { lng: 113.768745, lat: 22.93173 },
// { lng: 113.76945, lat: 22.930731 },
// { lng: 113.772022, lat: 22.93014 },
// { lng: 108.952789, lat: 34.348938 },
// ],
],
}
},
mounted() {},
@ -122,78 +98,56 @@ export default {
//
initMap() {
this.$nextTick(() => {
// //
// this.map = new BMapGL.Map('map')
// //
// this.map.centerAndZoom(new BMapGL.Point(116.297611, 40.047363), 18)
// //
// this.map.enableScrollWheelZoom(true)
// // setTimeout
// setTimeout(() => {
// // const startIcon = {
// // imgUrl: new URL('/src/assets/images/startIcon', import.meta.url).href,
// // position: [this.linePointList[0].lng, this.linePointList[0].lat],
// // size: [50, 50],
// // }
// // const endIcon = {
// // imgUrl: new URL('/src/assets/images/endIcon', import.meta.url).href,
// // position: [this.linePointList[this.linePointList.length - 1].lng, this.linePointList[linePointList.length - 1].lat],
// // size: [50, 50],
// // }
// this.initIcon(startIcon.imgUrl, startIcon.position, startIcon.size)
// this.initIcon(endIcon.imgUrl, endIcon.position, endIcon.size)
// }, 100)
this.map = new BMapGL.Map('container') //
let point = new BMapGL.Point(116.297611, 40.047363) //
let point = new BMapGL.Point(117.14, 31.87) //
console.log('🚀 ~ this.$nextTick ~ point:', point)
this.map.centerAndZoom(point, 15) //
this.map.enableScrollWheelZoom(true) //
//
setTimeout(async () => {
const startIcon = {
imgUrl: await import('/src/assets/images/startIcon.png'),
position: [linePointList[0].lng, linePointList[0].lat],
size: [50, 50],
}
const endIcon = {
imgUrl: await import('/src/assets/images/endIcon.png'),
position: [linePointList[linePointList.length - 1].lng, linePointList[linePointList.length - 1].lat],
size: [50, 50],
}
initIcon(startIcon.imgUrl, startIcon.position, startIcon.size)
initIcon(endIcon.imgUrl, endIcon.position, endIcon.size)
// initPolyline()
// initPolylineAnimation()
// setViewPortFn()
}, 200)
//
let pointList = []
for (var i = 0; i < this.linePointList.length; i++) {
pointList.push(new BMapGL.Point(this.linePointList[i].lng, this.linePointList[i].lat))
}
let pl = new BMapGL.Polyline(pointList)
let polyline = new BMapGL.Polyline(pointList)
// 线
polyline.setStrokeColor('#EA3323') // 线 #EA3323
// polyline.setStrokeWeight(2) // 线
let trackAni = new BMapGLLib.TrackAnimation(this.map, pl, {
let trackAni = new BMapGLLib.TrackAnimation(this.map, polyline, {
overallView: true, //
tilt: 30, // 55
duration: 10000, // 10000ms
delay: 3000, // 0ms
delay: 2000, // 0ms
})
//
this.simulateMovement()
trackAni.start()
})
},
initIcon(imgUrl, position, size) {
// var myIcon = new BMapGL.Icon("https://api.map.baidu.com/img/markers.png", new BMapGL.Size(50, 50));
var myIcon = new BMapGL.Icon(imgUrl, new BMapGL.Size(size))
// Marker使
var pt = new BMapGL.Point(...position)
var marker = new BMapGL.Marker(pt, {
icon: myIcon,
})
//
this.map.addOverlay(marker)
//
addStartEndMarkers(startLatLng, endLatLng) {
let startIcon = new BMapGL.Icon(require('/src/assets/images/startIcon.png'), new BMapGL.Size(32, 32))
let startMarker = new BMapGL.Marker(startLatLng, { icon: startIcon })
this.map.addOverlay(startMarker)
let endIcon = new BMapGL.Icon(require('/src/assets/images/endIcon.png'), new BMapGL.Size(32, 32))
let endMarker = new BMapGL.Marker(endLatLng, { icon: endIcon })
this.map.addOverlay(endMarker)
},
//
simulateMovement() {
//
let startLatLng = new BMapGL.Point(this.linePointList[0].lng, this.linePointList[0].lat)
let endLatLng = new BMapGL.Point(
this.linePointList[this.linePointList.length - 1].lng,
this.linePointList[this.linePointList.length - 1].lat
)
//
this.addStartEndMarkers(startLatLng, endLatLng)
},
},
}