Commit debf92b1 by 前端

Merge branch 'bugfix_change_map_2025-12-05' into 'master'

开发提测合并

See merge request !53
2 parents 579ff903 a094dff3
...@@ -43,7 +43,7 @@ h3.uimap-info-title{ ...@@ -43,7 +43,7 @@ h3.uimap-info-title{
background-color: #fff; background-color: #fff;
border-radius: 4px; border-radius: 4px;
border: 1px solid #eee; // border: 1px solid #eee;
.tit{ .tit{
padding: 10px 15px; padding: 10px 15px;
} }
......
...@@ -684,4 +684,7 @@ ...@@ -684,4 +684,7 @@
} }
.BMap_bubble_top{ .BMap_bubble_top{
height: 7px !important; height: 7px !important;
}
\ No newline at end of file \ No newline at end of file
}
// .BMap_bubble_bottom ~ img {
// top: 84px !important;
// }
...@@ -228,12 +228,12 @@ export default { ...@@ -228,12 +228,12 @@ export default {
}, },
methods: { methods: {
async initBMap() { async initBMap() {
console.log(11111111111); // console.log(11111111111);
this.mapObj = await mapService.init("map"); this.mapObj = await mapService.init("map");
this.mapLoading = false; this.mapLoading = false;
window.AMap = this.mapObj; window.AMap = this.mapObj;
AMap.invoke("LocalCity", (res) => { AMap.invoke("LocalCity", (res) => {
AMap.invoke('panTo',res.center) AMap.invoke("panTo", res.center);
}); });
this.autoComplete = AMap.invoke("Autocomplete", { this.autoComplete = AMap.invoke("Autocomplete", {
input: "tipInput", input: "tipInput",
...@@ -241,7 +241,7 @@ export default { ...@@ -241,7 +241,7 @@ export default {
AMap.invoke("autocompleteShow"); AMap.invoke("autocompleteShow");
AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => { AMap.invoke("autocompleteAddEventListener", "onconfirm", (e) => {
this.poi = e.item.value; this.poi = e.item.value;
this.$set(this.form, "address", this.poi.address); this.$set(this.form, "address", this.poi.address || "");
this.$refs.addressInput.focus(); this.$refs.addressInput.focus();
}); });
...@@ -303,7 +303,7 @@ export default { ...@@ -303,7 +303,7 @@ export default {
{ {
isOpen: true, // 是否开启绘制模式 isOpen: true, // 是否开启绘制模式
enableDrawingTool: false, enableDrawingTool: false,
enableCalculate: true, // 绘制是否进行测距测面 // enableCalculate: true, // 绘制是否进行测距测面
enableSorption: true, // 是否开启边界吸附功能 enableSorption: true, // 是否开启边界吸附功能
sorptiondistance: 20, // 边界吸附距离 sorptiondistance: 20, // 边界吸附距离
circleOptions: styleOptions, // 圆的样式 circleOptions: styleOptions, // 圆的样式
...@@ -382,7 +382,7 @@ export default { ...@@ -382,7 +382,7 @@ export default {
southWest.lat, southWest.lat,
northEast.lng northEast.lng
); // 南到北的距离 ); // 南到北的距离
console.log(width, height); // console.log(width, height);
this.rectangleHeight = width.toFixed(0); this.rectangleHeight = width.toFixed(0);
this.rectangleWidth = height.toFixed(0); this.rectangleWidth = height.toFixed(0);
}, },
...@@ -557,7 +557,7 @@ export default { ...@@ -557,7 +557,7 @@ export default {
let m = o.gpsLocation || {}; let m = o.gpsLocation || {};
o.lng = m.blng; o.lng = m.blng;
o.lat = m.blat; o.lat = m.blat;
o.address = m.address; o.address = m.address || "";
o.type = 2; o.type = 2;
o.time = m.dateTime; o.time = m.dateTime;
o.standNo = item.standNo || item.vin; o.standNo = item.standNo || item.vin;
...@@ -565,17 +565,43 @@ export default { ...@@ -565,17 +565,43 @@ export default {
arr.push(o); arr.push(o);
_this.location = o; _this.location = o;
}); });
_this.addMarkers(arr); _this.addMarkers(arr, false);
}); });
}); });
}, },
// 将坐标转换封装为返回 Promise 的函数
convertCoordinate(item) {
item = item.split(",");
return new Promise((resolve) => {
AMap.invoke(
"Convertor",
[AMap.invoke("Point", item[0], item[1])],
5,
3,
(res) => {
const convertedPoint = res.points.length ? res.points[0] : item;
resolve(convertedPoint);
}
);
});
},
AMapPoint2BMapPoint(AMapPoint, callback) {
AMap.invoke(
"Convertor",
[AMap.invoke("Point", AMapPoint.lng, AMapPoint.lat)],
3,
5,
(res) => {
const convertedPoint = res.points.length ? res.points[0] : item;
callback(convertedPoint);
}
);
},
// 区域查车 // 区域查车
async getAreaLocation() { async getAreaLocation() {
let _this = this; let _this = this;
let params = this.getParams(); let params = this.getParams();
let _options = this.$route.query; let _options = this.$route.query;
console.log(_options);
if (!_this.rectangle) { if (!_this.rectangle) {
showToast({ showToast({
...@@ -586,7 +612,7 @@ export default { ...@@ -586,7 +612,7 @@ export default {
_this.deviceList = []; _this.deviceList = [];
if (_this.mapMass) { if (_this.mapMass) {
AMap.invoke("clearOverlays"); // AMap.invoke("clearOverlays");
_this.mapMass = null; _this.mapMass = null;
} }
if (_options.type != "full") { if (_options.type != "full") {
...@@ -596,6 +622,10 @@ export default { ...@@ -596,6 +622,10 @@ export default {
_this.loading = true; _this.loading = true;
delete params.paths; delete params.paths;
let left = await this.convertCoordinate(params.leftLngLat);
let right = await this.convertCoordinate(params.rightLngLat);
params.leftLngLat = `${left.lng},${left.lat}`;
params.rightLngLat = `${right.lng},${right.lat}`;
let res = await GER_REGIONAL_SEARCH(params); let res = await GER_REGIONAL_SEARCH(params);
console.log(res, "res"); console.log(res, "res");
_this.loading = false; _this.loading = false;
...@@ -608,7 +638,7 @@ export default { ...@@ -608,7 +638,7 @@ export default {
let list = res.data || []; let list = res.data || [];
_this.deviceList = list; _this.deviceList = list;
_this.hideFooter = false; _this.hideFooter = false;
_this.addMarkers(list); _this.addMarkers(list, true);
}, },
// 在地图上画行政区域 // 在地图上画行政区域
...@@ -616,23 +646,30 @@ export default { ...@@ -616,23 +646,30 @@ export default {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode); EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
}, },
// 添加海量点 (MassMarks方式) // 添加海量点 (MassMarks方式)
addMarkers(arr) { addMarkers(arr, isTranslate) {
let _this = this; let _this = this;
let markers = []; let markers = [];
console.log(arr);
for (let i = 0, len = arr.length; i < len; i++) { for (let i = 0, len = arr.length; i < len; i++) {
let k = arr[i]; let k = arr[i];
console.log(k);
let lnglat = mapService.getLngLat(k.lng, k.lat); let lnglat = mapService.getLngLat(k.lng, k.lat);
let marker = mapService.createCarMarker(lnglat); if (isTranslate) {
markers.push(marker); this.AMapPoint2BMapPoint(lnglat, (translateLngLat) => {//写死了 高德地图转百度地图 TODO: 动态判断
AMap.invoke("addOverlay", marker); let marker = _this._createMarker(translateLngLat,k);
AMap.invoke("panTo", lnglat); markers.push(marker);
AMap.invoke("markerAddEventListener", "click", (e) => { // let marker = mapService.createCarMarker(carPoint);
console.log(e); // markers.push(marker);
let infoWindow = mapService.createAraeInfowindow(k); // AMap.invoke("addOverlay", marker);
AMap.invoke("mapOpenInfoWindow", infoWindow, e.target.getPosition()); // AMap.invoke("panTo", lnglat);
}); // AMap.invoke("markerAddEventListener", "click", (e) => {
// console.log(e);
// let infoWindow = mapService.createAraeInfowindow(k);
// AMap.invoke("mapOpenInfoWindow", infoWindow, e.target.getPosition());
// });
});
} else {
let marker = _this._createMarker(lnglat,k);
markers.push(marker);
}
} }
this.drawDone = true; this.drawDone = true;
// if (arr && arr.length < 10) { // if (arr && arr.length < 10) {
...@@ -641,12 +678,23 @@ export default { ...@@ -641,12 +678,23 @@ export default {
this.mapMass = markers; this.mapMass = markers;
}, },
_createMarker(lngLat,dataInfo) {
let marker = mapService.createCarMarker(lngLat);
AMap.invoke("addOverlay", marker);
AMap.invoke("panTo", lngLat);
AMap.invoke("markerAddEventListener", "click", (e) => {
let infoWindow = mapService.createAraeInfowindow(dataInfo);
AMap.invoke("mapOpenInfoWindow", infoWindow, e.target.getPosition());
});
return marker;
},
// 全屏状态下,根据参数初始化页面 // 全屏状态下,根据参数初始化页面
initPage(query) { initPage(query) {
console.log(query); console.log(query);
this.menuId = query.menuId; this.menuId = query.menuId;
if (query.address) { if (query.address) {
this.$set(this.form, "address", query.address); this.$set(this.form, "address", query.address || "");
} }
if (query.sn) { if (query.sn) {
this.$set(this.form, "sn", query.sn); this.$set(this.form, "sn", query.sn);
...@@ -668,7 +716,7 @@ export default { ...@@ -668,7 +716,7 @@ export default {
this.drawRectangle(query); this.drawRectangle(query);
this.getAreaLocation(); this.getAreaLocation();
this.autoComplete.setInputValue(this.form.address); this.autoComplete.setInputValue(this.form.address || "");
}, },
// 绘画矩形 // 绘画矩形
...@@ -787,4 +835,4 @@ export default { ...@@ -787,4 +835,4 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../assets/scss/zoneCar.scss"; @import "../../assets/scss/zoneCar.scss";
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -279,7 +279,6 @@ MapService.prototype = { ...@@ -279,7 +279,6 @@ MapService.prototype = {
return Circle return Circle
}, },
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) { createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
console.log(div,'div')
var self = this; var self = this;
var infoWindow=self.map.invoke('InfoWindow',div,{ var infoWindow=self.map.invoke('InfoWindow',div,{
enableAutoPan:!!isInfoAutoMove enableAutoPan:!!isInfoAutoMove
......
...@@ -60,30 +60,45 @@ const replay = { ...@@ -60,30 +60,45 @@ const replay = {
replay.distance=replay.dis.reduce(function (prev, cur, index, arr) { replay.distance=replay.dis.reduce(function (prev, cur, index, arr) {
return prev + cur; return prev + cur;
}); });
replay.distance=replay.distance/1000//算出轨迹的距离(km) console.log(replay.distance,9999999)
const firstItem = replay.data[0]; if(replay.distance){
replay.navg= AMap.invoke('LuShu', replayData, { replay.distance=replay.distance/1000//算出轨迹的距离(km)
defaultContent: replay.getNavgInfoContent(firstItem), const firstItem = replay.data[0];
autoView: true, // 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整 replay.navg= AMap.invoke('LuShu', replayData, {
speed: replay.getSpeed(replay.speed, replay.distance), defaultContent: replay.getNavgInfoContent(firstItem),
icon: AMap.invoke('Icon', 'https://e-shield-old.glsx.com.cn/images/icon_car.png', AMap.invoke('Size', 36, 22),{ anchor: AMap.invoke('Size',18, 11) }), autoView: true, // 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
enableRotation: true, // 是否设置marker随着道路的走向进行旋转 speed: replay.getSpeed(replay.speed, replay.distance),
}) icon: AMap.invoke('Icon', 'https://e-shield-old.glsx.com.cn/images/icon_car.png', AMap.invoke('Size', 36, 22),{ anchor: AMap.invoke('Size',18, 11) }),
AMap.invoke('lushuStart') //开始 enableRotation: true, // 是否设置marker随着道路的走向进行旋转
// AMap.invoke('lushuStop') //停止 })
// AMap.invoke('lushuPause') //暂停 AMap.invoke('lushuStart') //开始
// AMap.invoke('lushuShowInfoWindow') //打开信息窗口 // AMap.invoke('lushuStop') //停止
EventBus.$emit('uiMap.replay.initDone') // AMap.invoke('lushuPause') //暂停
AMap.invoke('lushuAddEventListener','move', (e) =>{ // AMap.invoke('lushuShowInfoWindow') //打开信息窗口
this.idx = e.target.i; EventBus.$emit('uiMap.replay.initDone')
let lnglat = replayData[this.idx] AMap.invoke('lushuAddEventListener','move', (e) =>{
let item=replay.data[this.idx] this.idx = e.target.i;
AMap.invoke('lushuSetContent',replay.getNavgInfoContent(item)) //设置信息窗口文案 let lnglat = replayData[this.idx]
EventBus.$emit('uiMap.replay.currAddress', ''); let item=replay.data[this.idx]
if(this.idx >= replay.data.length-3){ AMap.invoke('lushuSetContent',replay.getNavgInfoContent(item)) //设置信息窗口文案
EventBus.$emit('uiMap.replay.done'); EventBus.$emit('uiMap.replay.currAddress', '');
} if(this.idx >= replay.data.length-3){
}); EventBus.$emit('uiMap.replay.done');
}
});
}else{
//距离为0时,单独处理
const item = replay.data[ replay.data.length-1];
AMap.invoke('clearOverlays');
replay.Marker = mapService.createCarMarker(p2, AMap);
let infowindow= mapService.createInfoWindow(replay.Marker,AMap,replay.getNavgInfoContent(item))
AMap.invoke('addOverlay', replay.Marker )
AMap.invoke("mapOpenInfoWindow", infowindow,p2)
EventBus.$emit('uiMap.replay.initDone')
EventBus.$emit('uiMap.replay.done');
}
}, },
getDistance (p1, p2) { getDistance (p1, p2) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!