File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/service/PlotBase/SvgLoader/element Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 22/*
33 * @Author : your name
44 * @Date : 2021-09-14 18:57:30
5- * @LastEditTime : 2022-05-23 13:40:03
5+ * @LastEditTime : 2022-06-08 17: 13:57
66 * @LastEditors : zk
77 * @Description : In User Settings Edit
88 * @FilePath : \MapGISPlotBase\src\svg-loader\element\TSapnElement.js
@@ -161,10 +161,24 @@ class TSpanElement extends TextElement {
161161 const bounds = new Bounds ( ) ;
162162 const fontSize = this . getStyle ( 'font-size' ) . getNumber ( ) ;
163163 const width = this . _getMeasureTextWidth ( ) ;
164+
164165 const pos = this . getPos ( width ) ;
166+
167+ let del = - width / 2
168+ const textAnchorProps = this . getStyle ( 'text-anchor' ) ;
169+ if ( textAnchorProps . hasValue ( ) ) {
170+ const s = textAnchorProps . getString ( ) ;
171+ if ( s === 'middle' ) {
172+ del = 0 ;
173+ } else if ( s === 'end' ) {
174+ del = width / 2 ;
175+ }
176+ }
177+
165178 const matrix = this . _getMatrix ( ) ;
179+
166180 bounds . addPnt ( pos . x , pos . y - fontSize ) ;
167- bounds . addPnt ( pos . x + width , pos . y ) ;
181+ bounds . addPnt ( pos . x + width - del , pos . y ) ;
168182 bounds . applyMatrix3 ( matrix ) ;
169183 return bounds ;
170184 }
You can’t perform that action at this time.
0 commit comments