Fix adding and immediately removing a Layer from the map when the map is never initialized

This commit is contained in:
danzel 2014-01-30 16:15:03 +13:00
parent 064902665e
commit 2396a10282
2 changed files with 8 additions and 2 deletions

View File

@ -376,6 +376,12 @@ describe("Map", function () {
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);
});
describe("when the last tile layer on a map is removed", function () {
it("fires a zoomlevelschange event", function () {
map.whenReady(function () {

View File

@ -56,8 +56,8 @@ L.Layer = L.Evented.extend({
this.onRemove(map);
}
if (this.getAttribution && this._map.attributionControl) {
this._map.attributionControl.removeAttribution(this.getAttribution());
if (this.getAttribution && map.attributionControl) {
map.attributionControl.removeAttribution(this.getAttribution());
}
if (this.getEvents) {