index.js (741B)
1 import L from 'leaflet'; 2 import './style.css'; 3 4 function enableTopRow(control) { 5 const originalOnAdd = control.onAdd; 6 if (control._topRowEnabled) { 7 return; 8 } 9 10 L.Util.extend(control, { 11 _topRowEnabled: true, 12 13 onAdd: function(map) { 14 const container = originalOnAdd.call(this, map); 15 setTimeout(() => this.__injectTopRow(), 0); 16 return container; 17 }, 18 19 __injectTopRow: function() { 20 this._topRow = L.DomUtil.create('div', 'leaflet-control-layers-top-row'); 21 this._form.parentNode.insertBefore(this._topRow, this._form); 22 } 23 24 }); 25 if (control._map) { 26 control.__injectTopRow(); 27 } 28 } 29 30 export default enableTopRow;