File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -434,4 +434,9 @@ summary {
434
434
z-index : 1000 ;
435
435
pointer-events : none;
436
436
position : relative;
437
+ }
438
+
439
+ .mapml-layer-remove-button {
440
+ margin-left : 15px ;
441
+ text-decoration : none;
437
442
}
Original file line number Diff line number Diff line change @@ -494,6 +494,18 @@ export var MapMLLayer = L.Layer.extend({
494
494
opacityControlSummaryLabel = document . createElement ( 'label' ) ,
495
495
mapEl = this . _layerEl . parentNode ;
496
496
497
+ let removeButton = document . createElement ( 'a' ) ;
498
+ removeButton . href = '#' ;
499
+ removeButton . role = 'button' ;
500
+ removeButton . title = 'Remove Layer' ;
501
+ removeButton . innerHTML = "<span aria-hidden='true'>✖</span>" ;
502
+ removeButton . classList . add ( 'mapml-layer-remove-button' ) ;
503
+ L . DomEvent . disableClickPropagation ( removeButton ) ;
504
+ L . DomEvent . on ( removeButton , 'click' , L . DomEvent . stop ) ;
505
+ L . DomEvent . on ( removeButton , 'click' , ( e ) => {
506
+ mapEl . removeChild ( e . target . closest ( "fieldset" ) . querySelector ( "span" ) . layer . _layerEl ) ;
507
+ } , this ) ;
508
+
497
509
input . defaultChecked = this . _map ? true : false ;
498
510
input . type = 'checkbox' ;
499
511
input . className = 'leaflet-control-layers-selector' ;
@@ -598,6 +610,7 @@ export var MapMLLayer = L.Layer.extend({
598
610
fieldset . appendChild ( details ) ;
599
611
details . appendChild ( summary ) ;
600
612
summary . appendChild ( label ) ;
613
+ summary . appendChild ( removeButton ) ;
601
614
details . appendChild ( opacityControl ) ;
602
615
603
616
if ( this . _styles ) {
You can’t perform that action at this time.
0 commit comments