Files
mosr-web/src/views/custom-query/topo/utils/anchor/update.js
2024-03-04 19:13:43 +08:00

31 lines
810 B
JavaScript

/**
* @author: clay
* @data: 2019/08/15
* @description: update anchor
*/
export default function(cfg, group) {
let { anchorPoints, width, height, id } = cfg
if (anchorPoints && anchorPoints.length) {
for (let i = 0, len = anchorPoints.length; i < len; i++) {
let [x, y] = anchorPoints[i]
// 计算Marker中心点坐标
let originX = -width / 2
let originY = -height / 2
let anchorX = x * width + originX
let anchorY = y * height + originY
// 锚点背景
let anchorBgShape = group.findById(id + '_anchor_bg_' + i)
// 锚点
let anchorShape = group.findById(id + '_anchor_' + i)
anchorBgShape.attr({
x: anchorX,
y: anchorY
})
anchorShape.attr({
x: anchorX,
y: anchorY
})
}
}
}