Repository navigation
[core] Implement "smart setStyle" - #9256
Conversation
0e88d58 to
83287e2
Compare
|
Beautiful @jfirebaugh! |
|
RIP style classes |
83287e2 to
6490e5d
Compare
|
Updated the description and this is ready for review. |
#9270 tracks documenting this default on iOS and macOS. |
There was a problem hiding this comment.
within the style via the "transition" property (support added in this PR)
Does the root property affect the transition to or from the style it’s on? If the former, then is it the case that, by the time the developer has the opportunity to set this property, the transition will’ve already commenced? If the latter, this documentation would need to be updated.
/cc @boundsj |
The value from the new style takes precedence, so the former.
No, the user has opportunities to override the style default. When using When using |
|
Sounds good. In that case, the A more natural way to expose transition options to the SDKs would involve something like |
f27cb58 to
fa6b7ad
Compare
fa6b7ad to
75fbdad
Compare
|
So to clarify, Referencing discussion in: #6180 My current code: func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) {
//Fired each time map is changed (changing styles)
//
// Set up Map Data/Styles only once!
//
guard let style = mapView.style else {
print("Can't load styles yet! You shouldn't be seeing this!!")
return
}
//add sources
//add layers
....
} |
|
setStyleUrl {y.mango_measure}[Setup]: loading style failed: Attempt to invoke virtual method 'java.lang.String okhttp3.HttpUrl.host()' on a null object reference |
Implements automatic "smart setStyle" behavior for existing style-setting APIs:
Map::setStyleURLandMap::setStyleJSON. Both of these APIs will now smoothly transition between the prior and new style (providing equivalent layers/sources/etc. use the same IDs).Besides the obvious behavioral change, several changes are worth calling out for consideration of their downstream impact:
Map::setTransitionOptions(already existed), or within the style via the"transition"property (support added in this PR). A 300ms transition was always the intended default behavior according to the style specification, and is what's implemented in gl-js, but for whatever reason was not the default for gl-native. This change is included because it makes smart setStyle look cool.Map::setStyleURL, the prior style remains in effect until the asynchronous network request for the new style has completed. Previously, the map would have an empty style in the interim. This caused flashing and flickering which, if not fixed, would be especially noticeable with smart setStyle.Styleobject held byMaphas a lifetime coincident with theMaplifetime itself. This was the most straightforward implementation of the prior point, but I think it's also a reasonable change on the grounds that it eliminates corner cases from the API. Specifically:Mapnow actually has an (empty) style from the get go. Previously, runtime styling APIs were explicitly no-ops or errors prior to a style being loaded.Map::setStyleURL/setStyleJSONupdate the existing internal style object in place, rather than creating a new one. There isn't currently aMap::getStylemethod, so this is unlikely to be an externally visible change. If we addMap::setStyle(std::unique_ptr<Style>), it will replace the existing style object, rather than updating it in place.Fixes #7893.
TODO:
set-style-*integration tests and make sure they pass