@@ -10,13 +10,13 @@ describe('Geometry.Edit', function () {
10
10
point . _add ( offset ) ;
11
11
}
12
12
happen . mousedown ( eventContainer , {
13
- 'clientX' :point . x ,
14
- 'clientY' :point . y
13
+ 'clientX' : point . x ,
14
+ 'clientY' : point . y
15
15
} ) ;
16
16
for ( var i = 0 ; i < 10 ; i ++ ) {
17
17
happen . mousemove ( document , {
18
- 'clientX' :point . x + i ,
19
- 'clientY' :point . y + i
18
+ 'clientX' : point . x + i ,
19
+ 'clientY' : point . y + i
20
20
} ) ;
21
21
}
22
22
happen . mouseup ( document ) ;
@@ -107,7 +107,7 @@ describe('Geometry.Edit', function () {
107
107
it ( 'not all markers can be edited' , function ( ) {
108
108
for ( var i = 0 ; i < COMMON_SYMBOL_TESTOR . markerSymbols . length ; i ++ ) {
109
109
var symbol = COMMON_SYMBOL_TESTOR . markerSymbols [ i ] ;
110
- var marker = new maptalks . Marker ( center , { symbol :symbol } ) ;
110
+ var marker = new maptalks . Marker ( center , { symbol : symbol } ) ;
111
111
marker . addTo ( layer ) ;
112
112
marker . startEdit ( ) ;
113
113
if ( symbol [ 'text-name' ] ) {
@@ -129,10 +129,10 @@ describe('Geometry.Edit', function () {
129
129
130
130
it ( 'resize a vector marker' , function ( ) {
131
131
var marker = new maptalks . Marker ( map . getCenter ( ) , {
132
- symbol : {
133
- markerType :'ellipse' ,
134
- markerWidth :20 ,
135
- markerHeight :20
132
+ symbol : {
133
+ markerType : 'ellipse' ,
134
+ markerWidth : 20 ,
135
+ markerHeight : 20
136
136
}
137
137
} ) . addTo ( layer ) ;
138
138
var size = marker . getSize ( ) ;
@@ -159,17 +159,17 @@ describe('Geometry.Edit', function () {
159
159
160
160
it ( 'resize a vector marker with fix aspect ratio' , function ( ) {
161
161
var marker = new maptalks . Marker ( map . getCenter ( ) , {
162
- symbol : {
163
- markerType :'ellipse' ,
164
- markerWidth :20 ,
165
- markerHeight :20
162
+ symbol : {
163
+ markerType : 'ellipse' ,
164
+ markerWidth : 20 ,
165
+ markerHeight : 20
166
166
}
167
167
} ) . addTo ( layer ) ;
168
168
var fired = false ;
169
169
marker . on ( 'resizing' , function ( ) {
170
170
fired = true ;
171
171
} ) ;
172
- marker . startEdit ( { 'fixAspectRatio' : true } ) ;
172
+ marker . startEdit ( { 'fixAspectRatio' : true } ) ;
173
173
var size = marker . getSize ( ) ;
174
174
dragGeometry ( marker , new maptalks . Point ( size . width / 2 , 0 ) ) ;
175
175
var symbol = marker . getSymbol ( ) ;
@@ -259,7 +259,7 @@ describe('Geometry.Edit', function () {
259
259
ellipse . on ( 'resizing' , function ( ) {
260
260
fired = true ;
261
261
} ) ;
262
- ellipse . startEdit ( { 'fixAspectRatio' : true } ) ;
262
+ ellipse . startEdit ( { 'fixAspectRatio' : true } ) ;
263
263
var size = ellipse . getSize ( ) ;
264
264
var ratio = ellipse . getWidth ( ) / ellipse . getHeight ( ) ;
265
265
dragGeometry ( ellipse , new maptalks . Point ( size . width / 2 , 0 ) ) ;
@@ -307,7 +307,7 @@ describe('Geometry.Edit', function () {
307
307
rect . on ( 'resizing' , function ( ) {
308
308
fired = true ;
309
309
} ) ;
310
- rect . startEdit ( { 'fixAspectRatio' : true } ) ;
310
+ rect . startEdit ( { 'fixAspectRatio' : true } ) ;
311
311
var size = rect . getSize ( ) ;
312
312
var ratio = rect . getWidth ( ) / rect . getHeight ( ) ;
313
313
dragGeometry ( rect , new maptalks . Point ( size . width / 2 , 0 ) ) ;
@@ -334,7 +334,7 @@ describe('Geometry.Edit', function () {
334
334
var size = polygon . getSize ( ) ;
335
335
dragGeometry ( polygon , new maptalks . Point ( size . width / 2 , size . height / 2 ) ) ;
336
336
expect ( polygon . toGeoJSON ( ) ) . not . to . be . eqlGeoJSON ( o ) ;
337
- var expected = { "type" :"Feature" , "geometry" :{ "type" :"Polygon" , "coordinates" :[ [ [ 118.84682499999997 , 32.04653400000004 ] , [ 118.85742312186676 , 32.04653400000004 ] , [ 118.85751916135894 , 32.04196057399085 ] , [ 118.84682499999997 , 32.04204242358057 ] , [ 118.84682499999997 , 32.04653400000004 ] ] ] } , "properties" :null } ;
337
+ var expected = { "type" : "Feature" , "geometry" : { "type" : "Polygon" , "coordinates" : [ [ [ 118.84682499999997 , 32.04653400000004 ] , [ 118.85742312186676 , 32.04653400000004 ] , [ 118.85751916135894 , 32.04196057399085 ] , [ 118.84682499999997 , 32.04204242358057 ] , [ 118.84682499999997 , 32.04653400000004 ] ] ] } , "properties" : null } ;
338
338
expect ( polygon . toGeoJSON ( ) ) . to . be . eqlGeoJSON ( expected ) ;
339
339
340
340
polygon . undoEdit ( ) ;
@@ -351,17 +351,17 @@ describe('Geometry.Edit', function () {
351
351
expect ( polygon . getCoordinates ( ) [ 0 ] . length ) . to . be ( 5 ) ;
352
352
353
353
polygon . startEdit ( {
354
- 'removeVertexOn' : 'contextmenu'
354
+ 'removeVertexOn' : 'contextmenu'
355
355
} ) ;
356
356
var size = polygon . getSize ( ) ;
357
357
var domPosition = GET_PAGE_POSITION ( container ) ;
358
358
var point = map . coordinateToContainerPoint ( polygon . getCenter ( ) ) . add ( domPosition ) ;
359
359
point . _add ( new maptalks . Point ( size . width / 2 , size . height / 2 ) ) ;
360
360
361
361
happen . once ( eventContainer , {
362
- 'type' : 'contextmenu' ,
363
- 'clientX' :point . x ,
364
- 'clientY' :point . y
362
+ 'type' : 'contextmenu' ,
363
+ 'clientX' : point . x ,
364
+ 'clientY' : point . y
365
365
} ) ;
366
366
367
367
polygon . endEdit ( ) ;
@@ -370,8 +370,8 @@ describe('Geometry.Edit', function () {
370
370
371
371
it ( 'update symbol when editing' , function ( done ) {
372
372
var circle = new maptalks . Circle ( map . getCenter ( ) , 1000 , {
373
- symbol : {
374
- 'polygonFill' : '#f00'
373
+ symbol : {
374
+ 'polygonFill' : '#f00'
375
375
}
376
376
} ) . addTo ( layer ) ;
377
377
circle . startEdit ( ) ;
@@ -384,11 +384,32 @@ describe('Geometry.Edit', function () {
384
384
done ( ) ;
385
385
} ) ;
386
386
circle . updateSymbol ( {
387
- 'polygonFill' : '#ff0'
387
+ 'polygonFill' : '#ff0'
388
388
} ) ;
389
389
} ) ;
390
390
} ) ;
391
391
} ) ;
392
392
393
+ it ( 'polygon edit collision' , function ( done ) {
394
+ const c = 0.00001 ;
395
+ const polygon = new maptalks . Polygon ( [ [ [ 0 , 0 ] , [ c , 0 ] , [ c , c ] , [ 0 , c ] , [ 0 , 0 ] ] ] )
396
+ polygon . addTo ( layer ) ;
397
+
398
+ var spy = sinon . spy ( ) ;
399
+ polygon . on ( 'handlecollision' , spy ) ;
400
+
401
+ map . setZoom ( 3 ) ;
402
+ setTimeout ( ( ) => {
403
+ polygon . startEdit ( {
404
+ collision :true
405
+ } ) ;
406
+ setTimeout ( ( ) => {
407
+ expect ( spy . called ) . to . be . ok ( ) ;
408
+ polygon . endEdit ( ) ;
409
+ done ( ) ;
410
+ } , 100 ) ;
411
+ } , 200 ) ;
412
+ } ) ;
413
+
393
414
394
415
} ) ;
0 commit comments