mirror of
https://github.com/umap-project/umap.git
synced 2025-05-05 14:01:50 +02:00
Compute _layers for MarkerCluster, so to easily know if layer has data
This commit is contained in:
parent
c6ded31daa
commit
5dda33f5e4
1 changed files with 17 additions and 4 deletions
|
@ -10,6 +10,10 @@ L.U.Layer = {
|
||||||
},
|
},
|
||||||
|
|
||||||
postUpdate: function () {},
|
postUpdate: function () {},
|
||||||
|
|
||||||
|
hasDataVisible: function () {
|
||||||
|
return !!Object.keys(this._layers).length
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
L.U.Layer.Default = L.FeatureGroup.extend({
|
L.U.Layer.Default = L.FeatureGroup.extend({
|
||||||
|
@ -53,6 +57,17 @@ L.U.Layer.Cluster = L.MarkerClusterGroup.extend({
|
||||||
}
|
}
|
||||||
L.MarkerClusterGroup.prototype.initialize.call(this, options)
|
L.MarkerClusterGroup.prototype.initialize.call(this, options)
|
||||||
this._markerCluster = L.U.MarkerCluster
|
this._markerCluster = L.U.MarkerCluster
|
||||||
|
this._layers = []
|
||||||
|
},
|
||||||
|
|
||||||
|
addLayer: function (layer) {
|
||||||
|
this._layers.push(layer)
|
||||||
|
return L.MarkerClusterGroup.prototype.addLayer.call(this, layer)
|
||||||
|
},
|
||||||
|
|
||||||
|
removeLayer: function (layer) {
|
||||||
|
this._layers.splice(this._layers.indexOf(layer), 1)
|
||||||
|
return L.MarkerClusterGroup.prototype.removeLayer.call(this, layer)
|
||||||
},
|
},
|
||||||
|
|
||||||
getEditableOptions: function () {
|
getEditableOptions: function () {
|
||||||
|
@ -266,7 +281,7 @@ L.U.DataLayer = L.Evented.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
hasDataVisible: function () {
|
hasDataVisible: function () {
|
||||||
return !!Object.keys(this.layer._layers).length
|
return this.layer.hasDataVisible()
|
||||||
},
|
},
|
||||||
|
|
||||||
resetLayer: function (force) {
|
resetLayer: function (force) {
|
||||||
|
@ -981,9 +996,7 @@ L.U.DataLayer = L.Evented.extend({
|
||||||
buildVersionsFieldset: function (container) {
|
buildVersionsFieldset: function (container) {
|
||||||
const appendVersion = function (data) {
|
const appendVersion = function (data) {
|
||||||
const date = new Date(parseInt(data.at, 10))
|
const date = new Date(parseInt(data.at, 10))
|
||||||
const content = `${date.toLocaleString(L.lang)} (${
|
const content = `${date.toLocaleString(L.lang)} (${parseInt(data.size) / 1000}Kb)`
|
||||||
parseInt(data.size) / 1000
|
|
||||||
}Kb)`
|
|
||||||
const el = L.DomUtil.create('div', 'umap-datalayer-version', versionsContainer)
|
const el = L.DomUtil.create('div', 'umap-datalayer-version', versionsContainer)
|
||||||
const a = L.DomUtil.create('a', '', el)
|
const a = L.DomUtil.create('a', '', el)
|
||||||
L.DomUtil.add('span', '', el, content)
|
L.DomUtil.add('span', '', el, content)
|
||||||
|
|
Loading…
Reference in a new issue