|
@ -1,4 +1,5 @@ |
|
|
import { loadAMap } from "@screen/pages/Home/components/AMapContainer/loadAMap.js"; |
|
|
import { loadAMap } from "@screen/pages/Home/components/AMapContainer/loadAMap.js"; |
|
|
|
|
|
import { Message } from "element-ui"; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @typedef {Object} Point |
|
|
* @typedef {Object} Point |
|
@ -24,6 +25,8 @@ export async function setMarkerCluster(map, points, markerFun) { |
|
|
|
|
|
|
|
|
let hasClick = false; |
|
|
let hasClick = false; |
|
|
|
|
|
|
|
|
|
|
|
if (!points.length) Message.warning("匹配到对应坐标点"); |
|
|
|
|
|
|
|
|
const markerCluster = new AMap.MarkerCluster(map, points, { |
|
|
const markerCluster = new AMap.MarkerCluster(map, points, { |
|
|
// gridSize: 15,
|
|
|
// gridSize: 15,
|
|
|
maxZoom: 15, |
|
|
maxZoom: 15, |
|
@ -94,7 +97,7 @@ export async function setMarkerCluster(map, points, markerFun) { |
|
|
* @param {*} _markerClick marker 点击 |
|
|
* @param {*} _markerClick marker 点击 |
|
|
* @returns |
|
|
* @returns |
|
|
*/ |
|
|
*/ |
|
|
export function setMarkToMap(item, data, resolveMarker, _markerClick) { |
|
|
export async function setMarkToMap(item, data, resolveMarker, _markerClick) { |
|
|
const { mapIns } = this.getMap(); |
|
|
const { mapIns } = this.getMap(); |
|
|
|
|
|
|
|
|
if (!mapIns) return Message.error("地图加载失败!"); |
|
|
if (!mapIns) return Message.error("地图加载失败!"); |
|
@ -118,7 +121,7 @@ export function setMarkToMap(item, data, resolveMarker, _markerClick) { |
|
|
_markerClick(extData, e); |
|
|
_markerClick(extData, e); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const markerCluster = setMarkerCluster( |
|
|
const markerCluster = await setMarkerCluster( |
|
|
mapIns, |
|
|
mapIns, |
|
|
data.map((item) => { |
|
|
data.map((item) => { |
|
|
const { lnglat, content } = resolveMarker(item); |
|
|
const { lnglat, content } = resolveMarker(item); |
|
@ -153,7 +156,11 @@ export function setMarkToMap(item, data, resolveMarker, _markerClick) { |
|
|
markerClick |
|
|
markerClick |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
mapIns.setFitView(markerCluster.U, false, [360, 360, 360, 360]); |
|
|
mapIns.setZoom(9); |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
mapIns.setFitView([...markerCluster.U], false, [0, 0, 0, 0]); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
return () => markerCluster.setMap(null); |
|
|
return () => markerCluster.setMap(null); |
|
|
} |
|
|
} |
|
|