Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Sets the loading flag in the style request handler to ensure that the… - #5581

Closed
PaulZed wants to merge 1 commit into
mapbox:masterfrom
PaulZed:staleStyleFix
Closed

PaulZed wants to merge 1 commit into
mapbox:masterfrom
PaulZed:staleStyleFix

Conversation

@PaulZed

@PaulZed PaulZed commented Jul 5, 2016

Copy link
Copy Markdown
Contributor

… correct Map event fires when a stale style gets refreshed from the server.

… correct Map event fires when a stale style gets refreshed from the server.
@jfirebaugh

Copy link
Copy Markdown
Contributor

I'm pretty sure we don't want to change the semantics of MapChangeDidFinishLoadingMap such that it fires more than once per call to setStyle{URL,JSON}. That would likely violate the assumptions of existing users of the event.

What's the underlying need you're trying to satisfy here?

@PaulZed

PaulZed commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

The problem here is that setStyle doesn't get called when a resource expires and is refetched. This means that the map reloads, but the MapChangeDidFinishLoadingMap event never fires, which is wrong. If someone is relying on that event to say, add a custom layer to the style, then when the style expires that custom layer will disappear forever, until the style is explicitly changed.

@PaulZed

PaulZed commented Jul 6, 2016 •

Copy link
Copy Markdown
Contributor Author

Perhaps a cleaner solution is to not keep the same request around to handle resource expiration, and explicitly call setStyleURL to load the new style when the resource expires. When a style expires the map is indeed reloaded, so the semantics may already not be working as you guys intend.

@PaulZed

PaulZed commented Jul 11, 2016

Copy link
Copy Markdown
Contributor Author

@tmpsantos @brunoabinader thoughts?

@brunoabinader

Copy link
Copy Markdown
Contributor

I suggest we add a new enum e.g. MapChangeDidFinishRefreshStyle - this ensures that the semantic concerns mentioned by @jfirebaugh are sustained while providing a mean for the client to be notified about it.

@tmpsantos

Copy link
Copy Markdown
Contributor

MapChangeDidFinishRefreshStyle

I like the idea.

@PaulZed

PaulZed commented Jul 12, 2016 •

Copy link
Copy Markdown
Contributor Author

I don't really understand what the difference is. If you have something that you want to happen whenever the map finishes loading, why wouldn't you want to do it when the map reloads? Can anyone actually come up with an example where semantics are being violated, because i'm struggling to.

Put another way, if I make a call to setStyle(), it will trigger a MapChangeDidFinishLoading. If the map refreshes, the style is still changed in the same mechanism; setStyleJSON is still called. The only difference is that the callback is not triggered. This seems like a bug to me, not a feature, and it seems semantically incorrect. If the style needs to reload, I think it's a safe assumption that the post-load hook needs to fire again.

@jfirebaugh

Copy link
Copy Markdown
Contributor

@PaulZed Thanks for bringing this to my attention. This exposed a wider issue with the intersection of runtime styling and style revalidation that I think needs discussion independent of this specific proposal. Opened #5665 for discussion.

@jfirebaugh jfirebaugh closed this Jul 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants