Ensure that getBounds can be called during the first moveend event
Fixes #1027
This commit is contained in:
parent
87bc14d968
commit
fbf91fef54
@ -1 +1,14 @@
|
||||
describe("Map", noSpecs);
|
||||
describe("Map", function () {
|
||||
describe("#getBounds", function () {
|
||||
it("is safe to call from within a moveend callback during initial load (#1027)", function () {
|
||||
var c = document.createElement('div'),
|
||||
map = L.map(c);
|
||||
|
||||
map.on("moveend", function () {
|
||||
map.getBounds();
|
||||
});
|
||||
|
||||
map.setView([51.505, -0.09], 13);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -517,6 +517,9 @@ L.Map = L.Class.extend({
|
||||
|
||||
this._tileLayersToLoad = this._tileLayersNum;
|
||||
|
||||
var loading = !this._loaded;
|
||||
this._loaded = true;
|
||||
|
||||
this.fire('viewreset', {hard: !preserveMapOffset});
|
||||
|
||||
this.fire('move');
|
||||
@ -527,8 +530,7 @@ L.Map = L.Class.extend({
|
||||
|
||||
this.fire('moveend', {hard: !preserveMapOffset});
|
||||
|
||||
if (!this._loaded) {
|
||||
this._loaded = true;
|
||||
if (loading) {
|
||||
this.fire('load');
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user