Skip to content

Commit 73f45e6

Browse files
authored
Merge pull request #3 from avvertix/panel-label
Add optional label to show before the controls
2 parents 58ae010 + a41c8ed commit 73f45e6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ collapsed: false or true
3636
//The position of the control (one of the map corners).
3737
position: 'topleft' or 'topright' or 'bottomleft' or 'bottomright'
3838

39+
//Optional label to present before the controls (e.g. "Layers Opacity")
40+
label: string or null
41+
3942
```
4043

4144
<br>

src/L.Control.Opacity.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
L.Control.Opacity = L.Control.extend({
22
options: {
33
collapsed: false,
4-
position: 'topright'
4+
position: 'topright',
5+
label: null
56
},
67
initialize: function (overlays, options) {
78
L.Util.setOptions(this, options);
@@ -41,6 +42,11 @@ L.Control.Opacity = L.Control.extend({
4142
container.setAttribute('aria-haspopup', true);
4243
L.DomEvent.disableClickPropagation(container);
4344
L.DomEvent.disableScrollPropagation(container);
45+
if(this.options.label){
46+
var labelSpan = L.DomUtil.create('span', className + "-label");
47+
labelSpan.innerHTML = this.options.label;
48+
container.appendChild(labelSpan);
49+
}
4450
var form = this._form = L.DomUtil.create('form', className + '-list');
4551
if (collapsed) {
4652
this._map.on('click', this.collapse, this);

0 commit comments

Comments
 (0)