parent
b804b5bc41
commit
e20eeba89a
4 changed files with 19 additions and 3 deletions
|
@ -648,9 +648,10 @@ L.U.Map.include({
|
||||||
filter = L.DomUtil.create('input', '', browserContainer),
|
filter = L.DomUtil.create('input', '', browserContainer),
|
||||||
filterValue = '',
|
filterValue = '',
|
||||||
featuresContainer = L.DomUtil.create('div', 'umap-browse-features', browserContainer),
|
featuresContainer = L.DomUtil.create('div', 'umap-browse-features', browserContainer),
|
||||||
filterKeys = (this.options.filterKey || this.options.sortKey || 'name').split(',');
|
filterKeys = this.getFilterKeys();
|
||||||
filter.type = 'text';
|
filter.type = 'text';
|
||||||
filter.placeholder = L._('Filter…');
|
filter.placeholder = L._('Filter…');
|
||||||
|
filter.value = this.options.filter || '';
|
||||||
|
|
||||||
var addFeature = function (feature) {
|
var addFeature = function (feature) {
|
||||||
var feature_li = L.DomUtil.create('li', feature.getClassName() + ' feature'),
|
var feature_li = L.DomUtil.create('li', feature.getClassName() + ' feature'),
|
||||||
|
@ -709,14 +710,20 @@ L.U.Map.include({
|
||||||
};
|
};
|
||||||
|
|
||||||
var appendAll = function () {
|
var appendAll = function () {
|
||||||
|
this.options.filter = filterValue = filter.value;
|
||||||
featuresContainer.innerHTML = '';
|
featuresContainer.innerHTML = '';
|
||||||
filterValue = filter.value;
|
|
||||||
this.eachBrowsableDataLayer(function (datalayer) {
|
this.eachBrowsableDataLayer(function (datalayer) {
|
||||||
append(datalayer);
|
append(datalayer);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var resetLayers = function () {
|
||||||
|
this.eachBrowsableDataLayer(function (datalayer) {
|
||||||
|
datalayer.resetLayer(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
L.bind(appendAll, this)();
|
L.bind(appendAll, this)();
|
||||||
L.DomEvent.on(filter, 'input', appendAll, this);
|
L.DomEvent.on(filter, 'input', appendAll, this);
|
||||||
|
L.DomEvent.on(filter, 'input', resetLayers, this);
|
||||||
var link = L.DomUtil.create('li', '');
|
var link = L.DomUtil.create('li', '');
|
||||||
L.DomUtil.create('i', 'umap-icon-16 umap-caption', link);
|
L.DomUtil.create('i', 'umap-icon-16 umap-caption', link);
|
||||||
var label = L.DomUtil.create('span', '', link);
|
var label = L.DomUtil.create('span', '', link);
|
||||||
|
|
|
@ -1637,6 +1637,10 @@ L.U.Map.include({
|
||||||
|
|
||||||
search: function () {
|
search: function () {
|
||||||
if (this._controls.search) this._controls.search.openPanel(this);
|
if (this._controls.search) this._controls.search.openPanel(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
getFilterKeys: function () {
|
||||||
|
return (this.options.filterKey || this.options.sortKey || 'name').split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -228,10 +228,14 @@ L.U.DataLayer = L.Class.extend({
|
||||||
if (this.layer && this.options.type === this.layer._type && !force) return;
|
if (this.layer && this.options.type === this.layer._type && !force) return;
|
||||||
var visible = this.isVisible();
|
var visible = this.isVisible();
|
||||||
if (this.layer) this.layer.clearLayers();
|
if (this.layer) this.layer.clearLayers();
|
||||||
|
// delete this.layer?
|
||||||
if (visible) this.map.removeLayer(this.layer);
|
if (visible) this.map.removeLayer(this.layer);
|
||||||
var Class = L.U.Layer[this.options.type] || L.U.Layer.Default;
|
var Class = L.U.Layer[this.options.type] || L.U.Layer.Default;
|
||||||
this.layer = new Class(this);
|
this.layer = new Class(this);
|
||||||
|
var filterKeys = this.map.getFilterKeys(),
|
||||||
|
filter = this.map.options.filter;
|
||||||
this.eachLayer(function (layer) {
|
this.eachLayer(function (layer) {
|
||||||
|
if (filter && !layer.matchFilter(filter, filterKeys)) return;
|
||||||
this.layer.addLayer(layer);
|
this.layer.addLayer(layer);
|
||||||
});
|
});
|
||||||
if (visible) this.map.addLayer(this.layer);
|
if (visible) this.map.addLayer(this.layer);
|
||||||
|
|
|
@ -855,6 +855,7 @@ a.add-datalayer:hover,
|
||||||
background-image: url('./img/16.png');
|
background-image: url('./img/16.png');
|
||||||
display: inline;
|
display: inline;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.umap-add {
|
.umap-add {
|
||||||
background-position: -12px -49px;
|
background-position: -12px -49px;
|
||||||
|
@ -866,7 +867,7 @@ a.add-datalayer:hover,
|
||||||
background-position: -92px -168px;
|
background-position: -92px -168px;
|
||||||
}
|
}
|
||||||
.umap-caption {
|
.umap-caption {
|
||||||
background-position: -170px -49px;
|
background-position: -170px -52px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********************************* */
|
/* ********************************* */
|
||||||
|
|
Loading…
Reference in a new issue