added fix for touch enabled devices using the layer control
This commit is contained in:
parent
308b8e5f48
commit
2e71ad3060
@ -16,8 +16,46 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
*/
|
||||
|
||||
// queryable Layers control
|
||||
// [simply Control.Layers extended by query functions]
|
||||
// [simply Control.Layers extended by query functions and some fixes for touch screens]
|
||||
L.Control.QueryableLayers = L.Control.Layers.extend({
|
||||
|
||||
// changes to leaflet behaviour
|
||||
_initLayout: function () {
|
||||
this._container = L.DomUtil.create('div', 'leaflet-control-layers');
|
||||
L.DomEvent.disableClickPropagation(this._container); // change to Leaflet: always disable click propagation
|
||||
|
||||
this._form = L.DomUtil.create('form', 'leaflet-control-layers-list');
|
||||
|
||||
if (this.options.collapsed) {
|
||||
L.DomEvent.addListener(this._container, 'mouseover', this._expand, this);
|
||||
L.DomEvent.addListener(this._container, 'mouseout', this._collapse, this);
|
||||
|
||||
var link = this._layersLink = L.DomUtil.create('a', 'leaflet-control-layers-toggle');
|
||||
link.href = '#';
|
||||
link.title = 'Layers';
|
||||
|
||||
if (L.Browser.touch) {
|
||||
L.DomEvent.addListener(link, 'click', this._expand, this);
|
||||
L.DomEvent.disableClickPropagation(link); // change to Leaflet: disable click propagation
|
||||
} else {
|
||||
L.DomEvent.addListener(link, 'focus', this._expand, this);
|
||||
}
|
||||
this._map.on('movestart', this._collapse, this);
|
||||
// TODO keyboard accessibility
|
||||
|
||||
this._container.appendChild(link);
|
||||
} else {
|
||||
this._expand();
|
||||
}
|
||||
|
||||
this._baseLayersList = L.DomUtil.create('div', 'leaflet-control-layers-base', this._form);
|
||||
this._separator = L.DomUtil.create('div', 'leaflet-control-layers-separator', this._form);
|
||||
this._overlaysList = L.DomUtil.create('div', 'leaflet-control-layers-overlays', this._form);
|
||||
|
||||
this._container.appendChild(this._form);
|
||||
},
|
||||
|
||||
// new query functionality
|
||||
getActiveLayerName: function () {
|
||||
var i, input, obj,
|
||||
inputs = this._form.getElementsByTagName('input'),
|
||||
|
Loading…
Reference in New Issue
Block a user