Commit a094dff3 by liimin

Merge branch 'change-map' into bugfix_change_map_2025-12-05

2 parents 579ff903 7309f0b3
...@@ -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;
} }
......
...@@ -685,3 +685,6 @@ ...@@ -685,3 +685,6 @@
.BMap_bubble_top{ .BMap_bubble_top{
height: 7px !important; height: 7px !important;
} }
// .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) {
this.AMapPoint2BMapPoint(lnglat, (translateLngLat) => {//写死了 高德地图转百度地图 TODO: 动态判断
let marker = _this._createMarker(translateLngLat,k);
markers.push(marker); markers.push(marker);
AMap.invoke("addOverlay", marker); // let marker = mapService.createCarMarker(carPoint);
AMap.invoke("panTo", lnglat); // markers.push(marker);
AMap.invoke("markerAddEventListener", "click", (e) => { // AMap.invoke("addOverlay", marker);
console.log(e); // AMap.invoke("panTo", lnglat);
let infoWindow = mapService.createAraeInfowindow(k); // AMap.invoke("markerAddEventListener", "click", (e) => {
AMap.invoke("mapOpenInfoWindow", infoWindow, e.target.getPosition()); // 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 || "");
}, },
// 绘画矩形 // 绘画矩形
......
...@@ -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,6 +60,8 @@ const replay = { ...@@ -60,6 +60,8 @@ 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;
}); });
console.log(replay.distance,9999999)
if(replay.distance){
replay.distance=replay.distance/1000//算出轨迹的距离(km) replay.distance=replay.distance/1000//算出轨迹的距离(km)
const firstItem = replay.data[0]; const firstItem = replay.data[0];
replay.navg= AMap.invoke('LuShu', replayData, { replay.navg= AMap.invoke('LuShu', replayData, {
...@@ -84,6 +86,19 @@ const replay = { ...@@ -84,6 +86,19 @@ const replay = {
EventBus.$emit('uiMap.replay.done'); 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!