-
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
Fix Layer.addTo #1229
Merged
Merged
Fix Layer.addTo #1229
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VictorVelarde
changed the title
Temporary set MGL version to v0.50.0 in the Editor
Fix Layer.addTo
Jan 11, 2019
Note: all failing test 🔝 were |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1228
1. Relevant facts
Some facts about this problem:
map.setStyle(selectedBasemap
) vs the examples defining it usually within map's constructor options, with something likeconst map = new mapboxgl.Map({ style: carto.basemaps.positron ...
layer.addTo(map, "watername_ocean")
.map.on('load', addTheLayer);
... and that looks exactly like the situation here, so...2. What's happening?
Why isn't that catch working?
The error raising from the first addLayer is not been caught. The try & catch doesn't work here, as the error is an Event, not a common thrown Error (see https://www.mapbox.com/mapbox-gl-js/api/#map.event:error). So there is no way to catch it like that, and that looks like the error in the console. Moreover, the error 'message' doesn't correspond in this case with current regex.
So, has v0.52 changed the way to raise the errors here... ? Yes, it has in this particular case!. It looks like it was not evented before. See: mapbox/mapbox-gl-js#7539
There is also a new warning, which corresponds to these changes: mapbox/mapbox-gl-js#7562 but it doesn't look harmful.
And why is the layer eventually loading?
The editor code has two calls to addLayer, and the second one seems succesful, as the basemap is then ready. To clean that is something we should address in #1204, so it is out of scope here.
3. Fix
Make Layer.addTo able to deal with common error (as before) and evented error (new in MGL v0.52)