feat: unbounded horizontal scroll
Fixes #1582 (potentially eligible for bounty).
In a first approach I reused part of @ReinisSprogis' code regarding the camera using a -180,180 longitude.
The flash effect was due to tiles being somehow recreated when considered as from one world or another. The recreation is quick, but causes the flash effect. The solution is to consider tiles in a unique -180,180 world AND to maintain a list of tile positions at the same time.
For instance, scrolling from Europe to Alaska:
- Alaska is first considered as from the next world
- scrolling again, Alaska is considered as part of the current world, as the center of the map is now in America
- the flash fix is about reusing the same tile image for both positions (next world, current world)
I tested only in the Polygon example (that has no constraints), and manually dragging to the East (and tested to the West too). Let me know if there are typical examples that do not work with that PR.
I've shot a video but it seems too big for github.
New file:
-
tile_renderer.dart: Display of a [TileImage] at given [TileCoordinates].
Impacted files:
-
camera.dart: reused @ReinisSprogis' code - first I implemented inMapControllerImpl.dragUpdatedbut that was less generic -
tile.dart: additionalpositionCoordinatesfield -
tile_coordinates.dart: new factorykeywhich returns the same value for the same tile in all world replications -
tile_image.dart: typo fix -
tile_image_manager.dart: additional_positionCoordinatesfield -
tile_image_view.dart: additionalpositionCoordinatesfield -
tile_layer.dart: now using aTileRendererinstead of aTileImage -
tile_range.dart: now using a zoom modulo when checking if a coordinate fits into a range
Thank you @JaffaKetchup for your comments!
I'll have a look at the fling gesture bug.
Regarding the "teleporting" issue, it's somehow related to #1338. Currently, we just ask the projection: "hey, which is the one pixel that matches this LatLng?". And that's it. A solution would be to say: "by the way, is the map bigger than the world? In that case, replicate the markers in all matching places". And more specifically for #1338: "which is the closest LatLng-projected pixel to the previous polyline pixel, modulo the world size?" (instead of "which is the unique LatLng-projected pixel")
@JaffaKetchup I've just fixed the fling gesture bug.
The problem was that:
- the fling animator generates a list of increments
- for each increment, a new LatLng
- in the current standard projection, LatLng unprojection needs a pixel "in the world", or else it will truncate the longitude to -180 or 180
- that's why I introduced the size of the world, to be added or subtracted to the pixel X, during the fling effect
Remarks:
- Is there such thing as the size of the world in all projections?
- I haven't touched the standard unprojection method - that means that there may be other cases that would truncate the longitude and block to the end of the world.
@JaffaKetchup I've just pushed the changes you asked for.
Regarding the "teleporting" bug, I can work on it but it'd be better in a separate PR. There are already enough important code changes in the current PR to review, and from what I saw in the code each type of layer (marker, polygon, ...) would have to be individually impacted by the world repetitions: enough work for a distinct PR.
For handling multiple "worlds" with the other layers, I wonder if we could implement a buffer, then layer renders to a single buffer and then that buffer gets copied to the other world instances? that would cause trouble with culling for sure, but just throwing out the idea since its related to this PR
For handling multiple "worlds" with the other layers, I wonder if we could implement a buffer, then layer renders to a single buffer and then that buffer gets copied to the other world instances? that would cause trouble with culling for sure, but just throwing out the idea since its related to this PR
I don't think we should put too much effort in optimization in those cases, at least for the moment. I mean, "marker duplication in multiple world map" is still a very rare case, and we shouldn't jeopardize the 99% of the use cases just for that. That said, once the users are accustomed to those new features (unlimited scrolls + marker duplication) AND if they complain about performances, then we could have a look at it.
agreed, there are also some other things we would have to consider with that, having the non-tile layers just jump between the centered world is acceptable for now!
Thank you @mootw for your feedbacks! I've just pushed the latest changes (renamed variables).
Don't know if something specific is blocking the current PR.
Thank you @JaffaKetchup @mootw for your reviews! I can now focus on the "teleporting" markers.
My polar account is https://polar.sh/monsieurtanuki/
I've marked the issue as complete and paid the invoice, so hopefully you should recieve the bounty soon enough!
@JaffaKetchup Polar-wise, I still haven't received any money. As you sent it two week ago, I wonder if something is blocked somewhere.
Polar-wise, I still haven't received any money. As you sent it two week ago, I wonder if something is blocked somewhere.
It sounds like you haven't yet linked a Stripe account. Payouts go to a linked Stripe payouts account. As you've already made one for GitHub Sponsors I believe it should be much quicker (will remember your details I think).
For the record I've just edited details for Github Sponsors, but the polar set-up looks ok.
I've contacted the guys over at Polar, and it looks like it wasn't quite linked properly (it was linked to the organisation you setup, but not your personal account, which is where payouts are made, or something like that). He said he's linked it for you and made the payout, so hopefully should be with you at some point soon :)
Thank you very much @JaffaKetchup, I'm a bit richer now!
For the record, the $50 became $46.60 after fees ($3.40), and if I want to transfer it to my bank account there are additional fees of $2.48, leaving me with $44.12. And then the conversion to €, I guess.
Reminds me of restaurants in the US, where the prices are not the prices ("plus tax plus tip"). I even remember a campsite close to Monument Valley where they also mentioned "additional taxes". Too American for me: we decided to drive and eventually found an accommodation in a town called (you can't invent that) "Mexican Hat". But that's another story.