mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 03:05:28 +01:00
Fix layer control
This commit is contained in:
parent
82119dc32d
commit
94ecd3f495
@ -70,44 +70,7 @@ var DynmapLayerControl = L.Control.Layers.extend({
|
||||
this._lastZIndex++;
|
||||
layer.setZIndex(this._lastZIndex);
|
||||
}
|
||||
},
|
||||
|
||||
// Function override to convert the position-based ordering into the id-based ordering
|
||||
_onInputClick: function () {
|
||||
var i, input, obj,
|
||||
inputs = this._form.getElementsByTagName('input'),
|
||||
inputsLen = inputs.length,
|
||||
baseLayer;
|
||||
|
||||
this._handlingClick = true;
|
||||
|
||||
// Convert ID to pos
|
||||
var id2pos = {};
|
||||
for (i in this._layers) {
|
||||
id2pos[this._layers[i].id] = i;
|
||||
}
|
||||
|
||||
for (i = 0; i < inputsLen; i++) {
|
||||
input = inputs[i];
|
||||
obj = this._layers[id2pos[input.layerId]];
|
||||
|
||||
if (input.checked && !this._map.hasLayer(obj.layer)) {
|
||||
this._map.addLayer(obj.layer);
|
||||
if (!obj.overlay) {
|
||||
baseLayer = obj.layer;
|
||||
}
|
||||
} else if (!input.checked && this._map.hasLayer(obj.layer)) {
|
||||
this._map.removeLayer(obj.layer);
|
||||
}
|
||||
}
|
||||
|
||||
if (baseLayer) {
|
||||
this._map.setZoom(this._map.getZoom());
|
||||
this._map.fire('baselayerchange', {layer: baseLayer});
|
||||
}
|
||||
|
||||
this._handlingClick = false;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user