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