-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix e.isSourceLoaded to check if specific source is loaded #11393
Conversation
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.
The fix looks good, but is missing unit tests. There are similar tests in geojson_source.test.js
that could be amended to test all the events from a setData
call.
I tested against debug/geojson_update.html and found the following sequence of sourcedata
events for a GeoJSON source:
sourceDataType: metadata
: On first being added to the map and after the worker has loaded inline data or fetched and loaded from remote data.sourceDataType: content
: on subsequent calls tosetData
and after the worker has loaded inline data or fetched and loaded from remote data.sourceDataType: undefined
for each tile required to complete rendering the current frame.
e.isSourceLoaded
is false for every one of these emitted events until the last tile request is completed.
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.
Approved pending an additional unit test with GeoJsonSource#setData
showing that isSourceLoaded
changes to true.
@asheemmamoowala Thanks for the review! I added in a call to |
e.isSourceLoaded
is intended to return true if a source has no outstanding network requests (see docs for isSourceLoaded in the Map Data Event). Previously,e.isSourceLoaded
usedthis.loaded()
from style.js to determine its value.this.loaded()
in src/style/style.js however checks all sources to see if they are loaded rather than that specific source id. This fix uses the logic ofmap.isSourceLoaded
to check if that specific source id is loaded.Launch Checklist
mapbox-gl-js
changelog:<changelog>Fix e.isSourceLoaded to check if specific source has loaded.</changelog>