Add an overlay opacity slider

This commit is contained in:
Phyks (Lucas Verney) 2019-06-29 21:55:48 +02:00
parent 6b5be516d8
commit 7666daa10f
5 changed files with 73 additions and 13 deletions

View file

@ -20,6 +20,7 @@ BR.LayersTab = BR.ControlLayers.extend({
L.DomUtil.get('layers-control-wrapper').appendChild(this._section);
this.initOpacitySlider(map);
this.initButtons();
this.initJsTree();
@ -46,6 +47,31 @@ BR.LayersTab = BR.ControlLayers.extend({
);
},
initOpacitySlider: function(map) {
var self = this;
var overlayOpacitySlider = new BR.OpacitySlider({
id: 'overlay',
reversed: false,
orientation: 'horizontal',
defaultValue: 1,
title: i18next.t('layers.opacity-slider'),
callback: function(opacity) {
for (var i = 0; i < self._layers.length; i++) {
if (
!self._layers[i].overlay ||
!map.hasLayer(self._layers[i].layer)
) {
continue;
}
self._layers[i].layer.setOpacity(opacity);
}
}
}).onAdd(map);
L.DomUtil.get(
'leaflet-control-layers-overlays-opacity-slider'
).appendChild(overlayOpacitySlider);
},
initButtons: function() {
var expandTree = function(e) {
this.jstree.open_all();