一、需求来源
项目中会绘制许多条折线,用户要求实现鼠标悬浮在折线上时突出显示整条折线。
二、核心思想
- 为每个entity设置id,同时设置一个全局变量作为当前被选中的id;
- 在callbackproperty中判断当前选中的实体是否和自己属于同一条曲线,由此返回不同的属性值;
- 设置鼠标监听事件,根据鼠标悬浮的位置重置当前被选中的id;
三、效果
四、代码实现
1. 绘制曲线函数(包含callbackproperty的写法)
let selectEntityID = "";
function getAndDrawTrajectoryList() {
// var that = this;
// 异步
axios.get("http://localhost:5600/getTrajectoryList").then(
function (response) {
// 【1 - 利用http获取航迹数据并存到List中】
let TrajectoryList = response