-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve layer load #623
Improve layer load #623
Changes from 6 commits
35775b2
2a6bcb7
2f9a9da
5e21827
d22c842
9ec494d
462dc1f
380aaff
baa2abe
4cffafe
cf34620
f706ab4
9b78363
0d97a26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -376,12 +376,21 @@ export default class Layer { | |
} | ||
|
||
_addToMGLMap(map, beforeLayerID) { | ||
if (map.isStyleLoaded()) { | ||
this._isSourceLoaded = false; | ||
|
||
map.on('sourcedata', this._onMapSourcedata); | ||
map.on('load', this._onMapLoad.bind(this, map, beforeLayerID)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think map.on('load', this._onMapLoad.bind(this)); is more intuitive since we only bound the context but the parameters |
||
} | ||
|
||
_onMapSourcedata(event) { | ||
this._isSourceLoaded = event.isSourceLoaded; | ||
} | ||
|
||
_onMapLoad(map, beforeLayerID) { | ||
if (map.isStyleLoaded() || this._isSourceLoaded) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
map.off('sourcedata', this._onMapSourcedata); | ||
map.off('load', this._onMapLoad); | ||
this._onMapLoaded(map, beforeLayerID); | ||
} else { | ||
map.on('load', () => { | ||
this._onMapLoaded(map, beforeLayerID); | ||
}); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont we need to bind
this
here?