@@ -7,8 +7,8 @@ describe('Geometry.TextBox', function () {
7
7
8
8
beforeEach ( function ( ) {
9
9
var setups = COMMON_CREATE_MAP ( center , null , {
10
- width : 800 ,
11
- height : 600
10
+ width : 800 ,
11
+ height : 600
12
12
} ) ;
13
13
container = setups . container ;
14
14
map = setups . map ;
@@ -69,10 +69,10 @@ describe('Geometry.TextBox', function () {
69
69
var content = '中文标签' ;
70
70
var vector = new maptalks . TextBox ( content , center , 100 , 40 ) ;
71
71
var textStyle = {
72
- 'wrap' : true ,
73
- 'padding' : [ 12 , 8 ] ,
74
- 'verticalAlignment' : 'middle' ,
75
- 'horizontalAlignment' : 'middle'
72
+ 'wrap' : true ,
73
+ 'padding' : [ 12 , 8 ] ,
74
+ 'verticalAlignment' : 'middle' ,
75
+ 'horizontalAlignment' : 'middle'
76
76
} ;
77
77
vector . setTextStyle ( textStyle ) ;
78
78
//default textalign
@@ -162,19 +162,19 @@ describe('Geometry.TextBox', function () {
162
162
var padding = [ 12 , 8 ] ;
163
163
it ( 'left' , function ( ) {
164
164
var vector = new maptalks . TextBox ( '■■■' , center , 100 , 100 , {
165
- textStyle : {
166
- 'wrap' : true ,
167
- 'padding' : padding ,
168
- 'verticalAlignment' : 'middle' ,
169
- 'horizontalAlignment' : 'left'
165
+ textStyle : {
166
+ 'wrap' : true ,
167
+ 'padding' : padding ,
168
+ 'verticalAlignment' : 'middle' ,
169
+ 'horizontalAlignment' : 'left'
170
170
} ,
171
- boxSymbol : {
172
- 'markerType' : 'square' ,
173
- 'markerFillOpacity' : 0 ,
174
- 'markerLineOpacity' : 0
171
+ boxSymbol : {
172
+ 'markerType' : 'square' ,
173
+ 'markerFillOpacity' : 0 ,
174
+ 'markerLineOpacity' : 0
175
175
}
176
176
} ) ;
177
- layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
177
+ layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
178
178
map . addLayer ( layer ) ;
179
179
layer . addGeometry ( vector ) ;
180
180
expect ( layer ) . to . be . painted ( - 100 / 2 + padding [ 0 ] + 1 , 0 ) ;
@@ -184,19 +184,19 @@ describe('Geometry.TextBox', function () {
184
184
185
185
it ( 'right' , function ( ) {
186
186
var vector = new maptalks . TextBox ( '■■■' , center , 100 , 100 , {
187
- textStyle : {
188
- 'wrap' : true ,
189
- 'padding' : padding ,
190
- 'verticalAlignment' : 'middle' ,
191
- 'horizontalAlignment' : 'right'
187
+ textStyle : {
188
+ 'wrap' : true ,
189
+ 'padding' : padding ,
190
+ 'verticalAlignment' : 'middle' ,
191
+ 'horizontalAlignment' : 'right'
192
192
} ,
193
- boxSymbol : {
194
- 'markerType' : 'square' ,
195
- 'markerFillOpacity' : 0 ,
196
- 'markerLineOpacity' : 0
193
+ boxSymbol : {
194
+ 'markerType' : 'square' ,
195
+ 'markerFillOpacity' : 0 ,
196
+ 'markerLineOpacity' : 0
197
197
}
198
198
} ) ;
199
- layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
199
+ layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
200
200
map . addLayer ( layer ) ;
201
201
layer . addGeometry ( vector ) ;
202
202
expect ( layer ) . to . be . painted ( 100 / 2 - padding [ 0 ] - 2 , 0 ) ;
@@ -206,19 +206,19 @@ describe('Geometry.TextBox', function () {
206
206
207
207
it ( 'top' , function ( ) {
208
208
var vector = new maptalks . TextBox ( '■■■' , center , 100 , 100 , {
209
- textStyle : {
210
- 'wrap' : true ,
211
- 'padding' : padding ,
212
- 'verticalAlignment' : 'top' ,
213
- 'horizontalAlignment' : 'middle'
209
+ textStyle : {
210
+ 'wrap' : true ,
211
+ 'padding' : padding ,
212
+ 'verticalAlignment' : 'top' ,
213
+ 'horizontalAlignment' : 'middle'
214
214
} ,
215
- boxSymbol : {
216
- 'markerType' : 'square' ,
217
- 'markerFillOpacity' : 0 ,
218
- 'markerLineOpacity' : 0
215
+ boxSymbol : {
216
+ 'markerType' : 'square' ,
217
+ 'markerFillOpacity' : 0 ,
218
+ 'markerLineOpacity' : 0
219
219
}
220
220
} ) ;
221
- layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
221
+ layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
222
222
map . addLayer ( layer ) ;
223
223
layer . addGeometry ( vector ) ;
224
224
expect ( layer ) . to . be . painted ( 0 , - 100 / 2 + padding [ 1 ] + 7 ) ;
@@ -230,22 +230,32 @@ describe('Geometry.TextBox', function () {
230
230
return ;
231
231
}
232
232
var vector = new maptalks . TextBox ( '■■■' , center , 100 , 100 , {
233
- textStyle : {
234
- 'wrap' : true ,
235
- 'padding' : padding ,
236
- 'verticalAlignment' : 'bottom' ,
237
- 'horizontalAlignment' : 'middle'
233
+ textStyle : {
234
+ 'wrap' : true ,
235
+ 'padding' : padding ,
236
+ 'verticalAlignment' : 'bottom' ,
237
+ 'horizontalAlignment' : 'middle'
238
238
} ,
239
- boxSymbol : {
240
- 'markerType' : 'square' ,
241
- 'markerFillOpacity' : 0 ,
242
- 'markerLineOpacity' : 0
239
+ boxSymbol : {
240
+ 'markerType' : 'square' ,
241
+ 'markerFillOpacity' : 0 ,
242
+ 'markerLineOpacity' : 0
243
243
}
244
244
} ) ;
245
- layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
245
+ layer = new maptalks . VectorLayer ( 'id' , { 'drawImmediate' : true } ) ;
246
246
map . addLayer ( layer ) ;
247
247
layer . addGeometry ( vector ) ;
248
- expect ( layer ) . to . be . painted ( 0 , 100 / 2 - padding [ 1 ] - 9 ) ;
248
+ var parser = new UAParser ( ) ;
249
+ var offset = 8 ;
250
+ var result = parser . getOS ( ) ;
251
+ console . log ( result ) ;
252
+ if ( result . name ) {
253
+ if ( result . name . toLowerCase ( ) . indexOf ( 'linux' ) > - 1 ) {
254
+ offset = 9 ;
255
+ }
256
+ }
257
+
258
+ expect ( layer ) . to . be . painted ( 0 , 100 / 2 - padding [ 1 ] - offset ) ;
249
259
expect ( layer ) . not . be . painted ( ) ;
250
260
} ) ;
251
261
} ) ;
@@ -316,7 +326,7 @@ describe('Geometry.TextBox', function () {
316
326
} ) ;
317
327
318
328
it ( 'JSON of previous version\'s TextBox' , function ( ) {
319
- var json = { "content" :"岭南站/SM/A" , "feature" :{ "geometry" :{ "coordinates" :[ 113.120816 , 23.033914 ] , "type" :"Point" } , "id" :"NWP_LABEL_3" , "type" :"Feature" } , "options" :{ "boxAutoSize" :true , "boxMinHeight" :30 , "boxMinWidth" :100 , "boxPadding" :{ "height" :8 , "width" :15 } , "draggable" :true , "visible" :true , "zIndex" :1 } , "subType" :"TextBox" , "symbol" :{ "markerFill" :"#ffffff" , "markerFillOpacity" :1 , "markerHeight" :40 , "markerLineColor" :"#cccccc" , "markerLineOpacity" :0.8 , "markerLineWidth" :1 , "markerOpacity" :0.8 , "markerType" :"square" , "markerWidth" :140 , "opacity" :1 , "textDx" :0 , "textDy" :0 , "textFaceName" :"microsoft yahei" , "textFill" :"#000000" , "textHorizontalAlignment" :"middle" , "textLineSpacing" :1 , "textName" :"岭南站/SM/A" , "textOpacity" :0.8 , "textSize" :18 , "textSpacing" :0 , "textVerticalAlignment" :"middle" , "textWrapBefore" :false , "textWrapCharacter" :"\n" } } ;
329
+ var json = { "content" : "岭南站/SM/A" , "feature" : { "geometry" : { "coordinates" : [ 113.120816 , 23.033914 ] , "type" : "Point" } , "id" : "NWP_LABEL_3" , "type" : "Feature" } , "options" : { "boxAutoSize" : true , "boxMinHeight" : 30 , "boxMinWidth" : 100 , "boxPadding" : { "height" : 8 , "width" : 15 } , "draggable" : true , "visible" : true , "zIndex" : 1 } , "subType" : "TextBox" , "symbol" : { "markerFill" : "#ffffff" , "markerFillOpacity" : 1 , "markerHeight" : 40 , "markerLineColor" : "#cccccc" , "markerLineOpacity" : 0.8 , "markerLineWidth" : 1 , "markerOpacity" : 0.8 , "markerType" : "square" , "markerWidth" : 140 , "opacity" : 1 , "textDx" : 0 , "textDy" : 0 , "textFaceName" : "microsoft yahei" , "textFill" : "#000000" , "textHorizontalAlignment" : "middle" , "textLineSpacing" : 1 , "textName" : "岭南站/SM/A" , "textOpacity" : 0.8 , "textSize" : 18 , "textSpacing" : 0 , "textVerticalAlignment" : "middle" , "textWrapBefore" : false , "textWrapCharacter" : "\n" } } ;
320
330
var textBox = maptalks . Geometry . fromJSON ( json ) ;
321
331
expect ( textBox instanceof maptalks . TextBox ) . to . be . ok ( ) ;
322
332
expect ( maptalks . Util . extend ( { } , textBox . getTextStyle ( ) . symbol , textBox . getBoxSymbol ( ) ) ) . to . be . eql ( json . symbol ) ;
0 commit comments