Skip to content

Commit

Permalink
Merge pull request #3 from avvertix/panel-label
Browse files Browse the repository at this point in the history
Add optional label to show before the controls
  • Loading branch information
dayjournal committed Nov 4, 2018
2 parents 58ae010 + a41c8ed commit 73f45e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -36,6 +36,9 @@ collapsed: false or true
//The position of the control (one of the map corners).
position: 'topleft' or 'topright' or 'bottomleft' or 'bottomright'

//Optional label to present before the controls (e.g. "Layers Opacity")
label: string or null

```

<br>
Expand Down
8 changes: 7 additions & 1 deletion src/L.Control.Opacity.js
@@ -1,7 +1,8 @@
L.Control.Opacity = L.Control.extend({
options: {
collapsed: false,
position: 'topright'
position: 'topright',
label: null
},
initialize: function (overlays, options) {
L.Util.setOptions(this, options);
Expand Down Expand Up @@ -41,6 +42,11 @@ L.Control.Opacity = L.Control.extend({
container.setAttribute('aria-haspopup', true);
L.DomEvent.disableClickPropagation(container);
L.DomEvent.disableScrollPropagation(container);
if(this.options.label){
var labelSpan = L.DomUtil.create('span', className + "-label");
labelSpan.innerHTML = this.options.label;
container.appendChild(labelSpan);
}
var form = this._form = L.DomUtil.create('form', className + '-list');
if (collapsed) {
this._map.on('click', this.collapse, this);
Expand Down

0 comments on commit 73f45e6

Please sign in to comment.