Merge pull request #2421 from danzel/addremovebug
Fix adding and immediately removing a Layer from the map when the map is never initialized
This commit is contained in:
commit
38b43b4b5c
@ -376,6 +376,19 @@ describe("Map", function () {
|
|||||||
map.removeLayer(layer);
|
map.removeLayer(layer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("supports adding and removing a tile layer without initializing the map", function () {
|
||||||
|
var layer = L.tileLayer("{z}{x}{y}");
|
||||||
|
map.addLayer(layer);
|
||||||
|
map.removeLayer(layer);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("supports adding and removing a tile layer without initializing the map", function () {
|
||||||
|
map.setView([0, 0], 18);
|
||||||
|
var layer = L.tileLayer("{z}{x}{y}");
|
||||||
|
map.addLayer(layer);
|
||||||
|
map.removeLayer(layer);
|
||||||
|
});
|
||||||
|
|
||||||
describe("when the last tile layer on a map is removed", function () {
|
describe("when the last tile layer on a map is removed", function () {
|
||||||
it("fires a zoomlevelschange event", function () {
|
it("fires a zoomlevelschange event", function () {
|
||||||
map.whenReady(function () {
|
map.whenReady(function () {
|
||||||
|
@ -56,8 +56,8 @@ L.Layer = L.Evented.extend({
|
|||||||
this.onRemove(map);
|
this.onRemove(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getAttribution && this._map.attributionControl) {
|
if (this.getAttribution && map.attributionControl) {
|
||||||
this._map.attributionControl.removeAttribution(this.getAttribution());
|
map.attributionControl.removeAttribution(this.getAttribution());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getEvents) {
|
if (this.getEvents) {
|
||||||
|
@ -490,11 +490,12 @@ L.GridLayer = L.Layer.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_clearBgBuffer: function () {
|
_clearBgBuffer: function () {
|
||||||
var map = this._map;
|
var map = this._map,
|
||||||
|
bg = this._bgBuffer;
|
||||||
|
|
||||||
if (map && !map._animatingZoom && !map.touchZoom._zooming) {
|
if (map && !map._animatingZoom && !map.touchZoom._zooming && bg) {
|
||||||
this._bgBuffer.innerHTML = '';
|
bg.innerHTML = '';
|
||||||
L.DomUtil.setTransform(this._bgBuffer);
|
L.DomUtil.setTransform(bg);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user