@@ -716,9 +716,8 @@ describe('Draw & Edit Poly', () => {
716716 onStop ( ) {
717717 expect ( poly . pm . hasSelfIntersection ( ) ) . to . equal ( true ) ;
718718
719- const toucherSelfIntersectionFalse = handSelfIntersectionFalse . growFinger (
720- 'mouse'
721- ) ;
719+ const toucherSelfIntersectionFalse =
720+ handSelfIntersectionFalse . growFinger ( 'mouse' ) ;
722721 toucherSelfIntersectionFalse
723722 . wait ( 100 )
724723 . moveTo ( 504 , 337 , 100 )
@@ -744,9 +743,8 @@ describe('Draw & Edit Poly', () => {
744743 allowSelfIntersectionEdit : true ,
745744 } ) ;
746745
747- const toucherSelfIntersectionTrue = handSelfIntersectionTrue . growFinger (
748- 'mouse'
749- ) ;
746+ const toucherSelfIntersectionTrue =
747+ handSelfIntersectionTrue . growFinger ( 'mouse' ) ;
750748 toucherSelfIntersectionTrue
751749 . wait ( 100 )
752750 . moveTo ( 294 , 114 , 100 )
@@ -1280,4 +1278,53 @@ describe('Draw & Edit Poly', () => {
12801278 expect ( hintLine . options . color ) . to . eql ( 'red' ) ;
12811279 } ) ;
12821280 } ) ;
1281+
1282+ it ( 'snap to start marker instead of to the layer below' , ( ) => {
1283+ cy . window ( ) . then ( ( { map, L } ) => {
1284+ // it was not possible to create this test with creating the polygon by clicking
1285+ const polygon = L . polygon ( [
1286+ [
1287+ [ 20.53507732696281 , 71.98242187500001 ] ,
1288+ [ 19.87005983797396 , 71.97143554687501 ] ,
1289+ [ 19.782211275967995 , 73.35021972656251 ] ,
1290+ [ 20.55565240377338 , 73.48754882812501 ] ,
1291+ [ 20.53507732696281 , 71.98242187500001 ] ,
1292+ ] ,
1293+ ] ) ;
1294+ polygon . addTo ( map ) ;
1295+ map . fitBounds ( polygon . getBounds ( ) , { animate : false } ) ;
1296+ map . setZoom ( 8 , { animate : false } ) ;
1297+
1298+ map . pm . enableDraw ( 'Polygon' ) ;
1299+
1300+ map . pm . Draw . Polygon . _hintMarker . setLatLng ( [
1301+ 20.53837097209846 , 72.22334801861803 ,
1302+ ] ) ;
1303+ map . pm . Draw . Polygon . _createVertex ( {
1304+ latlng : [ 20.53837097209846 , 72.22334801861803 ] ,
1305+ } ) ;
1306+
1307+ map . pm . Draw . Polygon . _hintMarker . setLatLng ( [
1308+ 20.21581109239457 , 72.13073730468751 ,
1309+ ] ) ;
1310+ map . pm . Draw . Polygon . _createVertex ( {
1311+ latlng : [ 20.21581109239457 , 72.13073730468751 ] ,
1312+ } ) ;
1313+
1314+ map . pm . Draw . Polygon . _hintMarker . setLatLng ( [
1315+ 20.205501205844214 , 72.77893066406251 ,
1316+ ] ) ;
1317+ map . pm . Draw . Polygon . _createVertex ( {
1318+ latlng : [ 20.205501205844214 , 72.77893066406251 ] ,
1319+ } ) ;
1320+ } ) ;
1321+
1322+ cy . get ( mapSelector ) . trigger ( 'mousemove' , 413 , 180 ) ;
1323+
1324+ cy . window ( ) . then ( ( { map } ) => {
1325+ const hintMarker = map . pm . Draw . Polygon . _hintMarker ;
1326+ expect ( hintMarker . getLatLng ( ) . lat ) . to . eq ( 20.53837097209846 ) ;
1327+ expect ( hintMarker . getLatLng ( ) . lng ) . to . eq ( 72.22334801861803 ) ;
1328+ } ) ;
1329+ } ) ;
12831330} ) ;
0 commit comments