|
@@ -18,6 +18,8 @@ export function useAMap(options) {
|
|
const plotLayers = [];
|
|
const plotLayers = [];
|
|
// 标绘层级
|
|
// 标绘层级
|
|
let activeLayerkey;
|
|
let activeLayerkey;
|
|
|
|
+ // 显示信息框
|
|
|
|
+ let infoWindow;
|
|
// 初始化事件
|
|
// 初始化事件
|
|
const initMap = (options) => {
|
|
const initMap = (options) => {
|
|
window._AMapSecurityConfig = {
|
|
window._AMapSecurityConfig = {
|
|
@@ -241,8 +243,16 @@ export function useAMap(options) {
|
|
plotLayers['points2'].clearOverlays();
|
|
plotLayers['points2'].clearOverlays();
|
|
addPoints = [];
|
|
addPoints = [];
|
|
}
|
|
}
|
|
|
|
+ let hideInfoFlag = true;
|
|
Object.keys(obj).forEach((key: string) => {
|
|
Object.keys(obj).forEach((key: string) => {
|
|
const data = obj[key];
|
|
const data = obj[key];
|
|
|
|
+ if (clickMarker) {
|
|
|
|
+ const extData = clickMarker.getExtData();
|
|
|
|
+ if (data.id === extData.id) {
|
|
|
|
+ hideInfoFlag = false;
|
|
|
|
+ data.isHover = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (data.type === '3') {
|
|
if (data.type === '3') {
|
|
// 聚合点
|
|
// 聚合点
|
|
const div = document.createElement('div');
|
|
const div = document.createElement('div');
|
|
@@ -323,6 +333,10 @@ export function useAMap(options) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ if (hideInfoFlag) {
|
|
|
|
+ clickMarker = null;
|
|
|
|
+ hideInfo();
|
|
|
|
+ }
|
|
};
|
|
};
|
|
const getContent = (icon: string, size: number[], name?: string, color?: string = '#000') => {
|
|
const getContent = (icon: string, size: number[], name?: string, color?: string = '#000') => {
|
|
let content =
|
|
let content =
|
|
@@ -351,6 +365,8 @@ export function useAMap(options) {
|
|
plotLayers['points2'].clearOverlays();
|
|
plotLayers['points2'].clearOverlays();
|
|
addPoints = [];
|
|
addPoints = [];
|
|
}
|
|
}
|
|
|
|
+ clickMarker = null;
|
|
|
|
+ hideInfo();
|
|
};
|
|
};
|
|
let addressMarker;
|
|
let addressMarker;
|
|
// 设置灾害地点 单独图册
|
|
// 设置灾害地点 单独图册
|
|
@@ -373,8 +389,7 @@ export function useAMap(options) {
|
|
}
|
|
}
|
|
plotLayers['address'].addOverlay(addressMarker);
|
|
plotLayers['address'].addOverlay(addressMarker);
|
|
};
|
|
};
|
|
- // 显示信息框
|
|
|
|
- let infoWindow;
|
|
|
|
|
|
+
|
|
const showInfo = (content, position, offsetY, isCustom) => {
|
|
const showInfo = (content, position, offsetY, isCustom) => {
|
|
hideInfo();
|
|
hideInfo();
|
|
// 实例化InfoWindow
|
|
// 实例化InfoWindow
|
|
@@ -395,7 +410,7 @@ export function useAMap(options) {
|
|
infoWindow.on('mouseout', () => map.setStatus({ zoomEnable: true }));
|
|
infoWindow.on('mouseout', () => map.setStatus({ zoomEnable: true }));
|
|
};
|
|
};
|
|
|
|
|
|
- const hideInfo = (e) => {
|
|
|
|
|
|
+ const hideInfo = (e?: any) => {
|
|
map.setStatus({ zoomEnable: true });
|
|
map.setStatus({ zoomEnable: true });
|
|
if (!!infoWindow) {
|
|
if (!!infoWindow) {
|
|
infoWindow.close();
|
|
infoWindow.close();
|