-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Raster sources are not diffed properly by setStyle #3893
Comments
Thanks for such a clear report and test case @tgecho!
Yep, I agree this is probably the way we want to go. While I think in general we've tended to avoid storing passed-in |
@anandthakker Just found another similar case. Not sure if it's worth a full new issue. As an aside, we made a new fork of our internal style and this property appeared on all of our layers for some reason... |
@tgecho looks like your example there is using 0.29 -- could you check to see if this still occurs using the latest version (0.32.1)? |
Whoops. I was running an up-to-date version when I discovered it, but I forgot to update the fiddle when I cloned it. This still shows the issue: https://jsfiddle.net/g24hxLfq/1/ |
Style spec allows passing additional properties, which are quite handy. They do serialise nicely for vector sources, but unfortunately get lost for raster ones. |
I'm experiencing this issue on 0.37.0 when using |
fiddle here: https://jsfiddle.net/5yxgb3bs/3/ It seems like all the custom polygons and such remains intact but not the rasters |
any update on this? |
HI guys, sorry. I'm still having this issue under some circumstances with v.0.39.1. I updated the previous fiddle: https://jsfiddle.net/5yxgb3bs/7/. In the example I'm changing the
I suspect that the problem arise from this part of the style: "sources": {
"composite": {
"url": "mapbox://mapbox.mapbox-streets-v7",
"type": "vector"
},
"mapbox://mapbox.satellite": {
"url": "mapbox://mapbox.satellite",
"type": "raster",
"tileSize": 256
} But i can't be sure though. |
@cubodehelio That looks like a different issue; please open a new issue. |
mapbox-gl-js version: v0.29.0
Steps to Trigger Behavior
map.setStyle
a multiple times with the same raster source object.Expected Behavior
setStyle
should do nothing if the passed in style object is identical to the last one.Actual Behavior
The raster sources are removed and then added back every time even though nothing changed, causing an unpleasant flash.
In this fiddle, it calls
setStyle
with the same style object used to init the map after 3 seconds. Note that the raster tiles flash as they're reloaded. https://jsfiddle.net/e7co8ohd/4/This is happening because
RasterTileSource.serialize
returns the same object shape no matter what was passed in.If you don't specify any of these fields, the serialized version will still return them as
undefined
, which is unfortunately different from being not defined at all. In addition, if you have aurl
field you're not allowed to have atiles
field, but the source will include the tiles field it found at the url endpoint.My current ugly "fixed"
serialize
function looks like this. I can throw up a PR if it seems acceptable, but I feel like it might make more sense to try to preserve the original passed in spec more explicitly rather than special casing these fields.The text was updated successfully, but these errors were encountered: