Angular中的图像标注
创始人
2024-10-31 10:30:20
0
  1. 在Angular中使用ngx-avatar组件来显示图片和标注。该组件提供了添加标注和点击标注的功能。

  
  

  1. 创建一个Marker类型的对象来存储标注的信息,并添加到标注的列表中。
export class Marker {
  x: number;
  y: number;
  label: string;
}

markers: Marker[] = [
  { x: 30, y: 60, label: "Label 1" },
  { x: 70, y: 40, label: "Label 2" }
];
  1. 为点击标注时触发的事件编写onMarkerClick()函数。
onMarkerClick(marker: Marker) {
  console.log("Clicked marker:", marker);
}
  1. 添加新的标注使用addMarker()函数,该函数获取鼠标点击的位置并将其转换为相对于图像的坐标。
addMarker(event: MouseEvent): void {
  const x = event.offsetX / event.target.clientWidth * 100;
  const y = event.offsetY / event.target.clientHeight * 100;
  const label = "Label " + this.markers.length;
  this.markers.push({ x, y, label });
}
  1. 添加标注的按钮和事件侦听器。

相关内容

热门资讯

透视黑科技!wepoker破解... 透视黑科技!wepoker破解器激活码,epoker有透视吗,必胜教程(新版有挂)-哔哩哔哩1、we...
透视好牌!pokerworld... 透视好牌!pokerworld辅助器,wpk插件,透牌教程(有挂攻略)-哔哩哔哩1、操作简单,无需注...
透视有挂!hhpoker有没有... 透视有挂!hhpoker有没有外挂,购买wepoker模拟器,2025新版教程(存在有挂)-哔哩哔哩...
透视挂透视!wepoker辅助... 透视挂透视!wepoker辅助器下载,wepoker私人局辅助,2025新版技巧(有挂讲解)-哔哩哔...
透视脚本!德扑圈透视挂,wep... 透视脚本!德扑圈透视挂,wepoker怎么设置房间,可靠技巧(有挂技巧)-哔哩哔哩1、起透看视 we...
透视规律!wepoker透视底... 透视规律!wepoker透视底牌脚本,德普之星辅助工具如何设置,安装教程(有挂助手)-哔哩哔哩一、德...
透视安卓版!wpk有辅助器吗,... 透视安卓版!wpk有辅助器吗,wepokerplus作弊,AA德州教程(有挂技术)-哔哩哔哩小薇(透...
透视有挂!wepoker提高好... 透视有挂!wepoker提高好牌率,德州机器人代打脚本,介绍教程(有挂秘籍)-哔哩哔哩1、上手简单,...
透视黑科技!sohoo竞技联盟... 透视黑科技!sohoo竞技联盟辅助器,wepoker透视脚本免费使用视频,详细教程(有挂规律)-哔哩...
透视黑科技!pokemmo手机... 透视黑科技!pokemmo手机版脚本,wpk透视辅助方法,线上教程(讲解有挂)-哔哩哔哩1、不需要A...