-
-
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
Major State Refactoring #1551
Major State Refactoring #1551
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
ac8173e
to
c69d86f
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
Sure, I think that's probably a good idea! I've summarized in #1553, and we can continue the discussion there in the meantime. |
On another note, is this ready for a preliminary review, or did you have more short-term plans? |
4c18441
to
147b03c
Compare
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.
Just a few little nitpicks and questions, haven't gone through in detail yet. Feel free to argue if you think otherwise, I've probably misunderstood something.
147b03c
to
b371442
Compare
Actually I think I'm going to work on the InhertiedModel change so I would say wait for now. I do, however, have a question which as arised from refactoring. In My rough understanding right now is that |
I think... bounds is basically fitBounds (i.e on initialisation), i.e make the map fit as best possible to the bounds provided, but doesn't restrict during future pan/zoom iirc. maxbounds is basically, don't show outside these bounds at any point at all (to eliminate grey areas outside a map area for example on init and during pan/zooms). I think you're right on the pan ones, but it's a while since I've tried, so may need to double check the code for the adaptive boundaries thing (unless anyone else can remember specifically). |
Ah yep looks like you're right, it would be worth renaming this/center/zoom to initialBounds/initialCenter/initialZoom (with deprecations) as it's quite confusing.
Hmm this is where it gets confusing for me because that's what I though adaptive bounds is supposed to do? |
It's explained in the docs, and I'm not really a fan of making breaking changes just for naming, but that will affect all users, at the moment. Tbh, I can't remember what the point of adaptive boundaries was. I think it was based on screen size instead of coordinates, or something like that, but I have no idea. |
I think when people get confused, it's always worth revisiting what the concepts are, just in case there are tweaks in method names or documentation etc. After all if people ask, there's a reason, I certainly forget :D. I "think" there's separate things here though, i.e a boundary of the center you can drag to, vs a boundary of the edges displayed. |
I tried setting a bound limit on a personal project of mine not long ago but didn't bother in the end because As far as adaptive versus max bounds I've never used either so I'm also a bit lost. This is the relevant part of FlutterMapState's flutter_map/lib/src/map/state.dart Lines 406 to 420 in 79b54e4
It uses them as follows:
So we seem to have two different ways of trying to stay within the bounds. The next thing to figure out is why there is two and if we can combine them in to one. |
@ibrierley looks like you're right from an old comment of yours: #177 (comment) So I will integrate the various bounds options in to a single bounds option to make this clear. |
As always, I forget what I wrote in the past :D |
So adaptive bounds come from this PR and they were added to stop the visible bounds from going outside of the defined LatLng bounds. This was initially intended for an asset tile provider to prevent loading tiles for which there is no tile asset (if only within a certain range were downloaded).
These options were added for different reasons and, whilst I'm not 100% certain, they seem to essentially achieve the same thing: prevent viewing of coordinates outside of the defined LatLng boundary. The algorithms are different although they may be different ways of achieving the same thing, some testing will be needed to determine that and choose a preferred one. I did notice that P.S. P.P.S |
Hah yes, it's always been a bit confusing, but in some ways I'm not surprised, as it's not even always clear when talking about it :D. So firstly, maxBounds aim was to avoid grey areas and pretty much match leaflet.js implementation of maxBounds (hence why it's called that, and something not a bit more clear), i.e https://leafletjs.com/reference.html search for maxBounds "When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back if the user tries to pan outside the view." swPanBoundary (with adaptive off), seems to keep the center constrained to the boundary. Indeed adaptiveBoundaries true then appears to have the aim of keeping the visible area constrained, and it works similar, but if you zoom out for example, you will be able to see outside of the pan area (but can't pan). So it is more of a literal pan boundary, rather than a pure visible boundary. I also note in the original PR for adaptiveBoundaries it says "Caching a few tiles outside the boundaries is recommended for cases where the user is allowed to zoom out so much that the entire area fits on the screen." so the implication is that it won't limit in the same way. Here's an adjusted sliding_map example with markers draw at the boundary, just pop this in place of the existing example one in examples folder, and comment/uncomment the relevant lines around 32 & 39 to swap between them. I think I did test originally maxBounds with rotation, but annoyingly my mobile is bust to be able to tell properly whether this is the case (kinda hard to tell with just a manual force), so it would be good for someone to test that at least and see if it does work or not, and whether I'm imagining it :D. It's slightly annoying that there are two quite similar features, I suspect both are used, but may be wrong.
|
Thanks for having a look @ibrierley ! So I can confirm that on mobile web using the demo when I zoom all the way out and rotate the grey border is partially visible in the corners. I'd need to have a further look to determine if that's due to the algorithm or because the bounds limiting is not called in all the places is should be (e.g. when calling So right now I'm looking to create a MapBoundary base class with the following subclasses:
I'm thinking that
I wonder if I'm not attached to the names, if we can come up with names which better describe the behaviour I'm all for it. |
I was diving in to the various bounds implementations when I noticed #1549 and #1550 which add a new fit bounds method and add a fix for fit bounds, respectively. I'm hopeful that we can create a MapBounds abstraction which can encapsulate all of this. So then rather than adding a new fitCoordinates method to the controller we can have a MapCoordinateBounds subclass with its own implementation for determining if we are within the coordinate bounds and the center zoom required to be inside the coordiante bounds if we are not already. |
What about I've merged #1550, feel free to refactor it however. |
Hi @rorystephenson, I really like the idea of unifying the various types of boundaries and performing boundary checks for rotation! As far as unifying this with Using a collection of coordinates as a map boundary feels like a different and broader problem, and it could mean a few different things:
Fitting coordinates doesn't have this type of ambiguity; given a set of coordinates, there's really only one way to fit them on the map. So if we wanted to try to implement specific coordinate-based boundaries such as |
(
Whilst that would make logical sense, it's probably fine as it is. It's less work to import from an API or export to a storage medium. Open to argument though.
Of those options, I feel like bounding box and convex hull are enough for most users - and implementing arbitrary (potentially concave) polygon boundaries feels like it might be a lot of work (not saying a convex hull algorithm wouldn't be). |
b371442
to
58f017b
Compare
…idy up documentation None of the fields which were on the CameraFit base class were conceptually essential for any imaginable camera fit. Moving them to the subclasses ensures that any future camera fits will not need to implement those options just because they already exist. It would also allow for individual camera fits to specify different default values if appropriate.
Done 👍 I've also:
I don't feel strongly about the zoom limits for camera fit, happy to defer to @jjoelson and @Robbendebiene on that. |
The plugin API no longer exports classes which flutter_map already exports. Imports within this package now import the actual classes they use rather than the whole flutter_map library. Internal code should not depend on the exported library definition.
91b73c2
to
5d8aca1
Compare
I think where we landed is that it's OK for @JaffaKetchup Given that the old
I think that would be the best way to avoid unexpected behavior going forward, especially if we imagine that new fit types will be added in the future. |
@jjoelson Sorry for the slow response, I think having those defaults make sense. |
Your proposed defaults sound good @jjoelson , do you want to open a PR or shall I make the changes? |
Is this ready for a final review, or are more changes still needed? |
@JaffaKetchup I've just been upgrading some packages to use this branch:
Those deprecation changes were a result of that. Otherwise no other changes were needed for these plugins to work. So as far as I can see we are just missing the changed CameraFit defaults. |
The other parameters for CameraFit all have default values which will not cause changes to the calculated CameraFit (i.e. padding is zero, forceIntegerZoomLevel is false). Setting maxZoom to null makes it consistent with the other parameters in that it will not affect the calculated CameraFit. I chose null over double.infinity as in my opinion the intent is clearer, no maximum.
278bd42
to
c327723
Compare
@jjoelson and @JaffaKetchup I've just added a commit which updates the maxZoom default (the rest were already as suggested). I opted for null rather than double.infinity for the default value as I think that the intent is clearer; no maximum. It also makes it more explicit in the calculations. Let me know what you think. If you're both happy with I think we're ready to review and release a dev version for more testing. |
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.
LGTM for a preview release, although if bugs are found, a new PR will be needed, @rorystephenson if you're up for that.
Will try to merge the other remaining PRs before publishing the preview, and whilst those are being updated, I'm going to make a couple of changes in a PR as well. Just for reference, here's the v6 plan: https://github.com/fleaflet/flutter_map/projects/3.
Not sure if this is intentional or if I'm doing something wrong, but it seems like I can no longer access/import Edit: I guess |
This PR can be considered exploratory, prompted by #1547. I think overall the code quality is significantly improved but there are some major breaking changes so I want to see what other contributors think about these changes.
It's late where I am so I will try to update this summary better tomorrow or in the next couple of days but for now some highlights are:
Some more potential improvements which I haven't tackled yet, some of which are probably for another PR:
Consider merging PositionedTapDetector2 code in to the FlutterMapInteractiveViewer. This would mean we just have one gesture detector (raw gesture detector).