diff --git a/src/assets/mapUtils/map.ts b/src/assets/mapUtils/map.ts index 4464c4e..8a57989 100644 --- a/src/assets/mapUtils/map.ts +++ b/src/assets/mapUtils/map.ts @@ -9,6 +9,7 @@ import { defaultOption, getZoom, mapKey, mapPlugin } from '/@/assets/mapUtils/ma let AMap = null; export const Map = { + aMap: null, map: null, overlayGroup: null, // 地图中marker circleGroup: null, //直升机背景圆 @@ -19,6 +20,9 @@ export const Map = { infoWindow: null, //地图弹窗 driveLine: null, // 导航轨迹线 emergencyMarker: null, // 应急人员marker + startMarker: null, + endMarker: null, + clearSOrE: null, /** * @desc 地图舒适化 * @param el dom元素 id选择器 @@ -34,6 +38,7 @@ export const Map = { plugins: mapPlugin, // 需要使用的的插件列表,如比例尺'AMap.Scale'等 }).then((res) => { AMap = res; + this.aMap = res; const { zoom, center, mapStyle } = { ...defaultOption, ...option }; //基本地图加载 this.map = new AMap.Map(el, { @@ -476,4 +481,40 @@ export const Map = { this.clearNaviLine(); this.clearEmergencyMarker(); }, + createSMarker(position: any) { + if (this.startMarker) { + this.startMarker?.setMap(null); + this.startMarker = null; + } + + this.startMarker = new AMap.Marker({ + position: position, + offset: new AMap.Pixel(0, 0), + }); + this.map.add(this.startMarker); + this.setZoomCenter(position); + }, + createEMarker(position: any) { + if (this.endMarker) { + this.endMarker?.setMap(null); + this.endMarker = null; + } + + this.endMarker = new AMap.Marker({ + position: position, + offset: new AMap.Pixel(0, 0), + }); + this.map.add(this.endMarker); + this.setZoomCenter(position); + }, + clearSOrE() { + if (this.startMarker) { + this.startMarker?.setMap(null); + this.startMarker = null; + } + if (this.endMarker) { + this.endMarker?.setMap(null); + this.endMarker = null; + } + }, }; diff --git a/src/assets/mapUtils/mapConstant.ts b/src/assets/mapUtils/mapConstant.ts index c49f5a8..ae6d75f 100644 --- a/src/assets/mapUtils/mapConstant.ts +++ b/src/assets/mapUtils/mapConstant.ts @@ -23,7 +23,16 @@ export const innerLineLight = { // 地图key export const mapKey = '4bbcb216b889f2d612cbed05ae6979c8'; // 地图插件 -export const mapPlugin = ['AMap.ToolBar', 'AMap.Driving', 'AMap.GeoJSON', 'AMap.MarkerCluster', 'AMap.PlaceSearch', 'AMap.Driving', 'AMap.Geocoder']; +export const mapPlugin = [ + 'AMap.ToolBar', + 'AMap.Driving', + 'AMap.GeoJSON', + 'AMap.MarkerCluster', + 'AMap.PlaceSearch', + 'AMap.Driving', + 'AMap.Geocoder', + 'AMap.AutoComplete', +]; //根据数据量设置地图层级 export function getZoom(list = []) { diff --git a/src/views/indexSun.vue b/src/views/indexSun.vue index c9060aa..700f85f 100644 --- a/src/views/indexSun.vue +++ b/src/views/indexSun.vue @@ -105,7 +105,7 @@ import { handleSocketUrl, startTime } from '/@/utils/utils.ts'; import { useUserStore } from '/@/store/modules/user.ts'; - const { getCenterInfo } = useUserStore(); + const { getCenterInfo, setCount } = useUserStore(); import { oneLApi, roomDetailApi, @@ -273,6 +273,7 @@ watch(socketData, (nVal) => { if (nVal) { nextTick(() => { + setCount(); setSocketData(nVal); employeeDialogRef.value.openDialog(); }); @@ -285,6 +286,7 @@ const emergencyDialogRef = ref(); //紧急求助 watch(socketData1, (nVal) => { if (nVal) { + setCount(); setSocketData1(nVal); emergencyDialogRef.value.openDialog(); } diff --git a/src/views/indexSun/centerMap.vue b/src/views/indexSun/centerMap.vue index acfe699..1c2e7a8 100644 --- a/src/views/indexSun/centerMap.vue +++ b/src/views/indexSun/centerMap.vue @@ -2,17 +2,17 @@