Skip to content

Commit d7b39fe

Browse files
committed
Update for Leaflet version 1.x
1 parent aec89be commit d7b39fe

2 files changed

Lines changed: 14 additions & 20 deletions

File tree

dist/leaflet.select-layers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SelectLayers.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ L.Control.SelectLayers = L.Control.ActiveLayers.extend({
1515
L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation)
1616
}
1717

18-
var form = this._form = L.DomUtil.create('form', className + '-list')
18+
var section = this._section = L.DomUtil.create('section', className + '-list')
1919

2020
if (this.options.collapsed) {
2121
var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container)
@@ -26,37 +26,37 @@ L.Control.SelectLayers = L.Control.ActiveLayers.extend({
2626
L.DomEvent
2727
.on(link, 'click', L.DomEvent.stopPropagation)
2828
.on(link, 'click', L.DomEvent.preventDefault)
29-
.on(link, 'click', this._expand, this)
29+
.on(link, 'click', this.expand, this)
3030
} else {
3131
L.DomEvent
32-
.on(container, 'mouseover', this._expand, this)
33-
.on(container, 'mouseout', this._collapse, this)
34-
L.DomEvent.on(link, 'focus', this._expand, this)
32+
.on(container, 'mouseover', this.expand, this)
33+
.on(container, 'mouseout', this.collapse, this)
34+
L.DomEvent.on(link, 'focus', this.expand, this)
3535
}
3636

37-
this._map.on('movestart', this._collapse, this)
37+
this._map.on('movestart', this.collapse, this)
3838
} else {
39-
this._expand()
39+
this.expand()
4040
}
4141

42-
this._baseLayersList = L.DomUtil.create('select', className + '-base', form)
42+
this._baseLayersList = L.DomUtil.create('select', className + '-base', section)
4343
L.DomEvent.on(this._baseLayersList, 'change', this._onBaseLayerOptionChange, this)
4444

45-
this._separator = L.DomUtil.create('div', className + '-separator', form)
45+
this._separator = L.DomUtil.create('div', className + '-separator', section)
4646

47-
this._overlaysList = L.DomUtil.create('select', className + '-overlays', form)
47+
this._overlaysList = L.DomUtil.create('select', className + '-overlays', section)
4848
this._overlaysList.setAttribute('multiple', true)
4949
//extend across the width of the container
5050
this._overlaysList.style.width = '100%'
5151
L.DomEvent.on(this._overlaysList, 'change', this._onOverlayLayerOptionChange, this)
5252

53-
container.appendChild(form)
53+
container.appendChild(section)
5454
}
5555

5656
,_onBaseLayerOptionChange: function () {
5757
var selectedLayerIndex = this._baseLayersList.selectedIndex
5858
var selectedLayerOption = this._baseLayersList.options[selectedLayerIndex]
59-
var selectedLayer = this._layers[selectedLayerOption.layerId]
59+
var selectedLayer = this._getLayer(selectedLayerOption.layerId)
6060

6161
this._changeBaseLayer(selectedLayer)
6262
}
@@ -81,7 +81,7 @@ L.Control.SelectLayers = L.Control.ActiveLayers.extend({
8181
var options = this._overlaysList.options
8282
for (var i = 0; i < options.length; i++) {
8383
var option = options[i]
84-
var layer = this._layers[option.layerId].layer
84+
var layer = this._getLayer(option.layerId).layer
8585
if (option.selected) {
8686
if (!this._map.hasLayer(layer)) {
8787
this._map.addLayer(layer)
@@ -115,12 +115,6 @@ L.Control.SelectLayers = L.Control.ActiveLayers.extend({
115115
return option
116116
}
117117

118-
,_collapse: function (e) {
119-
if (e.target === this._container) {
120-
L.Control.Layers.prototype._collapse.apply(this, arguments)
121-
}
122-
}
123-
124118
})
125119

126120
L.control.selectLayers = function (baseLayers, overlays, options) {

0 commit comments

Comments
 (0)