-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
Reworked retina mode behaviour #1673
Conversation
…al testing Fixed attribution on Retina Tiles page
…uested, either via the server's {r} placeholder, or simulated.
Improved demo app Improved documentation
I've reworked the initial implementation a bit, let me know if you agree with what I've done.
|
Storing the BuildContext makes me uneasy, because that's not a pattern I see other widgets do, and atleast stackoverflow discourages it. If we accept it in the constructor we should quickly use and discard. |
@bramp Yes, you're quite right that it's bad practise to store a I've made some larger changes again, as I've realised some of what we did was not necessary.
For other combinations, "@2x" and "nothing" can still be used in the URL to achieve the desired result (ie. forcing simulation can be done just by omitting '{r}'). |
You mentioned about |
Thanks, ok it seems to be converging. Three general thoughts:
|
I don't really understand the purpose of maxZoom. At a certain level the TileLayer just hides itself. That seems a great feature if I'm intentionally displaying a overlap that I want to hide. But if this is the base layer, it seems a bad user experience to make the map just disappear. But yes, at a minimum I think maxNativeZoom needs to be changed. |
They are never
Whilst we could add a deprecation, I'm not sure it's in the best interest of users. Previously, it referred to simulating retina mode, but, as you found out, this was not very clear. This is such a different way of thinking of things that it might be more confusing to keep it in.
If we were to do that, then that might allow the collapsing of the two options as we have now. I'll see what I can figure out.
At the moment, there is no long term plan to refactor it - there are parts that are in more need of this kind of attention (for example, the gesture handling code). I'm also not sure which parts could be refactored out - they all directly relate to the display of tiles. Although it looks complex when looking at the source, most users will only use two or three properties.
That's why we're trying to dissuade it's usage from v6 onwards. There is indeed no good reason to use it on the base layer, however, there is no distinction between the base layer and other tile layers. |
At the moment, but in future code changes could change that invariant. Just defensive coding.
That's fair. I guess I read it as "use retina" but you are right, it was "simulate retina". So yes perhaps it would be a breaking change if we change it from simulate to use best method. But maybe that's a change for good? But if property is renamed, I do think the old one should stay there with a deprecation warning / assert failure, to help folks as they upgrade.
I was referring to the mix of WMS, and Network (subdomains, urlTemplate/fallbackUrl, etc). Asset Provider don't use url, but they do need paths (so the naming is a little inconsistent).... But you point is taken, there are perhaps better places. Ok as for this change. I raised my concerns, but happy for you to submit what you feel is best. One last change is to remove the API key from the Example. |
Introduced `RetinaMode.isHighDensity` Improved documentation Applied 'shrinking retina simulation' effect to native zoom boundaries
Let me know what you think of the latest commit, we've now massively simplified this, and I can't understand why it needed to be so complicated - my fault! In terms of deprecation, we're now using it again, so there's no opportunity for deprecation. I'll add the changes to the migration instructions. |
…etinaMode` enumerable
This is now resolved as well, re-using the |
Cool cool. So what's lost now, is allow folks to set which method they prefer (which make testing easier)? I guess that's ok because a user can control that with the |
Yep, I factored that in. No need to complicate |
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.
I know this was a lot of my commits, so I probably shouldn't be self approving this, but we need to get this moving to get v6 released at some point, so I'm bypassing normal processes :)!
Happy to make changes if any of the maintainers would like that.
Adds a new
retinaMethod
member toTileLayer
that takes the following values,auto
,server
, andsimulate
. As well as updated the Examples page to help test/debug.To avoid the issue with needing the BuildContext to get the device's density I left the boolean retinaMode to toggle the feature on and off. The idea is users can do this:
and it'll use the best method available (server, then simulate). However, they can override the method by setting TileLayer.retinaMethod.
Now, I think more work is needed with the min/maxZoom. It seems the intention is if the server supports 19, we should not allow zooming past 18 when simulating. Since at 18, the zoomOffset is actually fetching 19s. However, it seems to me that maxNativeZoom should be changed, not maxZoom. But before I go down that I wanted to get early feedback on the approach.
FYI, on my Mac (which has a 2x) you can very clearly see the improvement:
and finally, it seems desktops typically stick at 1x, but Android/iOS devices are all 3-4x these days.
thanks