fix:巡检信息修改地图

This commit is contained in:
2024-11-21 15:38:45 +08:00
parent 0a090e70d8
commit 151f95b06c
6 changed files with 794 additions and 599 deletions
+56 -13
View File
@@ -62,9 +62,9 @@ export default {
props: {
// 接收传过来得中心点
centerPoint: {
type: Object,
type: Array,
default: () => {
return { lat: 123.30297096718999, lon: 41.87942945541742 };
return [123.30297096718999, 41.87942945541742];
},
},
// 接受传过来得地图层级
@@ -90,7 +90,11 @@ export default {
// 地图控件位置
controlStyle: {
type: Object,
default: () => {},
default: () => {
return {
top: 0,
};
},
},
// 用于区分同一个页面多个地图的id
mapId: {
@@ -168,7 +172,10 @@ export default {
// this.changeImg("cva_c");
},
methods: {
/* 初始化openlayer地图 */
/**
* @description: 初始化openlayer地图
* @return {*}
*/
initMap() {
// const tianditu_vec_c = new TileLayer({
// className: "baseLayerClass",
@@ -207,7 +214,7 @@ export default {
rotate: false,
}),
view: new View({
center: [this.centerPoint.lat, this.centerPoint.lon], //中心点经纬度
center: this.centerPoint, //中心点经纬度
zoom: this.zoom, //图层缩放大小
projection: "EPSG:4326",
minZoom: 7,
@@ -307,11 +314,18 @@ export default {
this.instance.set("overlay-list", []);
},
/* 删除图层选择对象 */
/**
* @description: 删除图层选择对象
* @return {*}
*/
removeSelectClick() {
this.selectSingClick.getFeatures().clear();
},
/* 绘制地图 */
/**
* @description: 绘制地图
* @return {*}
*/
drawMap() {
if (this.drawMarkers.length < 1) {
const map = this.instance.get("map");
@@ -360,7 +374,12 @@ export default {
});
}
},
/* 监听绘制完成的事件 */
/**
* @description: 监听绘制完成的事件
* @param {*} event
* @return {*}
*/
drawend(event) {
const feature = event.feature;
const geometry = feature.getGeometry();
@@ -379,7 +398,12 @@ export default {
}
this.$emit("endEoordinate", this.drawMarkers);
},
/* 检测交叉点位方法 */
/**
* @description: 检测交叉点位方法
* @param {*} coordinates
* @return {*}
*/
isSelfCrossing(coordinates) {
for (let i = 0; i < coordinates.length - 1; i++) {
const segment1 = [coordinates[i], coordinates[i + 1]];
@@ -393,7 +417,13 @@ export default {
}
return false;
},
/* 检测交叉线段 */
/**
* @description: 检测交叉线段
* @param {*} segment1
* @param {*} segment2
* @return {*}
*/
doSegmentsCross(segment1, segment2) {
const [p1, p2] = segment1;
const [q1, q2] = segment2;
@@ -421,7 +451,11 @@ export default {
// 判断是否相交并且不是共线
return t > 0 && t < 1 && u > 0 && u < 1;
},
/* 删除绘制功能 */
/**
* @description: 删除绘制功能
* @return {*}
*/
deletedraw() {
const map = this.instance.get("map");
map.removeInteraction(this.draw);
@@ -434,7 +468,12 @@ export default {
this.drawMarkers = [];
this.$emit("endEoordinate", []);
},
/* 修改地图底图样式 */
/**
* @description: 修改地图底图样式
* @param {*} item
* @return {*}
*/
changeImg(item) {
if (this.mapType !== item) {
this.mapType = item;
@@ -487,6 +526,7 @@ export default {
});
}
},
/**
* @description: 切换当前位置
* @param {Array} position 中心点位置
@@ -517,7 +557,10 @@ export default {
map.removeLayer(layer);
},
/* 根据类型清除地图线段图层 */
/**
* @description: 根据类型清除地图线段图层
* @return {*}
*/
clearMapLine() {
const map = this.instance.get("map");
const [layer] = map