-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updates TextBox and Label #462
Comments
1、在将textBox的文本对齐方式变为:textBox.setTextVerticalAlignment(...)以后,Label与TextBox可以统一了,根据坐标调整的通过symbol去设置,针对文本的对齐通过上面的方法去调整; 2、autoSizeBox是针对box的设定,对于text与box的高与宽的变化,其实存在两种场景:其一,文本变化(编辑或赋值);其二,box变化。这两种场景下,存在另一方是否去适配对方新的大小的情况。 3、在box编辑的情况下,需要fitSize以适配新的box的width与height,可以统一一autoSizeBox(...),这个方法是根据文本来调整box的大小,在box存在的场景下,背景比文字区域小的场景都意义都是不大的,但是针对box的缩小调整,其实应该影响到text的textWrapWidth,这个应该可以通过上面textBox.setWidth/setHeight来实现,不过这个设置与textWrapWidth的是否需要配合就与上面第二点有些关联了; 4、自动缩减文字这个方法很有价值,它的使用场景是希望文本不要超出box,在实际场景中更应该是根据box的高宽自动去截取,这个方法应该可以配合autoSize:'box'来用; 5、box的padding的作用还是有的,所以如果取消了,势必需要一个类似的设置; 6、textMarker、Label、textBox的旋转功能。 |
我觉得TextBox和Label还是需要分开, 他们两不同点还是比较多, 分开后使用会更清晰一些
因为TextBox和Label没有auto时, 和普通marker没有区别, 所以应该都是自动的
最后, 旋转功能已经有了, symbol中: {
textRotation : 60
} |
删除 |
@brucin API方案: Label//自动调整markerWidth与markerHeight以适应文字高宽
var label = new maptalks.Label('label with box',
[0, 0],
{
'draggable' : true,
'boxStyle' : {
'padding' : [12, 8],
'verticalAlignment' : 'top',
'horizontalAlignment' : 'right',
'minWidth' : 300,
'minHeight' : 200,
'symbol' : {
'markerType' : 'square',
'markerFill' : 'rgb(135,196,240)',
'markerFillOpacity' : 0.9,
'markerLineColor' : '#34495e',
'markerLineWidth' : 1,
}
},
'textSymbol': {
// box's symbol
'textFaceName' : 'monospace',
'textFill' : '#34495e',
'textHaloFill' : '#fff',
'textHaloRadius' : 4,
'textSize' : 18,
'textWeight' : 'bold',
'textVerticalAlignment' : 'top'
}
});
label.setBoxStyle({
padding : [12, 8],
verticalAlignment : 'top',
horizontalAlignment : 'middle',
symbol : { .. }
});
label.setTextSymbol({
//...
}); TextBox// 自动调整textWrapWidth和缩减文字, 以自动适应box
var textBox = new maptalks.TextBox('A textbox',
[0, 0],
{
'draggable' : true,
'textStyle' : {
'wrap' : true,
'padding' : [12, 8],
'verticalAlignment' : 'top',
'horizontalAlignment' : 'right',
'symbol' : {
'textFaceName' : 'monospace',
'textFill' : '#34495e',
'textHaloFill' : '#fff',
'textHaloRadius' : 4,
'textSize' : 18,
'textWeight' : 'bold'
}
},
'boxSymbol': {
// box's symbol
'markerType' : 'square',
'markerFill' : 'rgb(135,196,240)',
'markerFillOpacity' : 0.9,
'markerLineColor' : '#34495e',
'markerLineWidth' : 1,
}
});
textBox.setTextStyle({
wrap : true,
padding : [12, 8],
verticalAlignment : 'middle', // 默认垂直居中
horizontalAlignment : 'middle', // 默认水平居中
symbol : { .. }
});
textBox.setWidth(400);
textBox.setHeight(100);
textBox.setBoxSymbol({
});
textBox.startEdit(); |
ConnectorLine 连接线的文字内容能否添加背景框 |
@brucin
根据之前的讨论, 以下是我对TextBox和Label初步的调整方案, 有什么我考虑不周全的地方, 随时讨论:
TextBox 和 Label 的区别
改造方案:
TextBox
Label
The text was updated successfully, but these errors were encountered: