调整已存在的测量注释
对于已经存在的测量注释,可以重新设置比例尺,单位,精确度等测量相关信息,而无需重新绘制该注释。
您可以通过以下步骤,调整已存在的测量注释的属性:
- 准备好需要被调整的注释。
- 使用
selectAnnotation
方法选中注释。 - 使用
setPropertyPanel
方法调整被选中的注释,传递的参数为一个对象,其中包含该注释所对应的测量工具中 default 和 defaultStyles 之中的任意属性,也可传递是否显示到注释外观的 showPerimeter、showArea、showRadius、showArcLength、showAngle 等UI属性,但请注意不能和其他属性共同传递。
以直线测量注释和矩形测量注释为例,以下是调整已存在的测量注释的示例代码:
javascript
const annotation = docViewer.annotations[0][0]; // 第一页的第一个注释。
if (annotation.measure && annotation.type === 'line') {
docViewer.selectAnnotation(annotation);
docViewer.setPropertyPanel({
precision: 1,
opacity: 0.5,
length: 3,
borderColor: '#2D77FA',
color: '#64BC38'
});
}
if (annotation.measure && annotation.type === 'rectangle') {
docViewer.selectAnnotation(annotation);
docViewer.setPropertyPanel({
precision: 0.01,
length: 5.45,
borderColor: '#64BC38',
fillColor: '#FFEC66',
fillTransparency: 0.5
});
docViewer.setPropertyPanel({ showPerimeter: true });
}