// 根据坐标点图片画框
addPicMarker(it, boundary, index) {
// Boundary:"666 116,666 159,712 159,712 116"(左下角,左上角,右上角,右下角)
// console.log(boundary)
const leftX = boundary.split(",")[0].split(" ")[0]
const rightX = boundary.split(",")[2].split(" ")[0]
const bottomY = boundary.split(",")[0].split(" ")[1]
const topY = boundary.split(",")[1].split(" ")[1]
const gMap = new AILabel.Map(`dialog${index}`, {
center: { x: 300, y: 174 }, // 根据图片在dom元素的宽高设置居中
zoom: 600,
mode: "PAN", // 绘制线
})
const gFirstImageLayer = new AILabel.Layer.Image(
`layer${index}`, // id
{
src: it,
width: 600, // 图片宽度
height: 348, // 图片高度
crossOrigin: false, // 图片是否跨域
position: {
// 图片左上角对应的坐标位置
x: 0,
y: 0,
},
}, // imageInfo
{ name: "第一个图片图层" }, // props
{ zIndex: 5 } // style
);
gMap.addLayer(gFirstImageLayer)
// Boundary:"666 116,666 159,712 159,712 116"(左下角,左上角,右上角,右下角)
const gFirstFeatureLayer = new AILabel.Layer.Feature(
`feature${index}`, // id
{ name: "第一个矢量图层" }, // props
{ zIndex: 10 } // style
);
gMap.addLayer(gFirstFeatureLayer);
const gFirstFeaturePolygon = new AILabel.Feature.Polygon(
`polygon${index}`, // id
{
points: [
// ()
{
x: leftX / (this.imgWidth / 600),
y: bottomY / (this.imgHeight / 348),
},
{
x: leftX / (this.imgWidth / 600),
y: topY / (this.imgHeight / 348),
},
{
x: rightX / (this.imgWidth / 600),
y: topY / (this.imgHeight / 348),
},
{
x: rightX / (this.imgWidth / 600),
y: bottomY / (this.imgHeight / 348),
},
],
}, // shape
{ name: "第一个多边形" }, // props
{ strokeStyle: "#FFD500", lineWidth: 2 } // style
)
gFirstFeatureLayer.addFeature(gFirstFeaturePolygon)
this.groupList[index].gmapLoading = false
// this.$set(this.relaGroup[index].tas)
this.gMap[index] = gMap
this.gFirstFeatureLayer[index] = gFirstFeatureLayer
this.gFirstImageLayer[index] = gFirstImageLayer
}
效果图呈现
备注:ai-label只能在已存在的dom元素中挂载
附官方链接:http://ailabel.com.cn/public/ailabel/api/index.html#103