flutter_map
flutter_map copied to clipboard
[BUG] Crossing W/E Extremity With `Polyline` Results In Unexpected Lines
What is the bug?
I was trying to implement a great circle map between two points using the OSM Map.
All is good as long as you don't cross 180E/W. Then the line suddenly jumps to the other side of the map.
What is the expected behaviour?
Having a closed line between the two points. On low zoom levels (like OSM 0), there should be just two renders of any layer at a given coordinate.
How can we reproduce this issue?
No response
Do you have a potential solution?
Maybe mirroring the coordinates is possible somehow? So that a marker or a line is shown twice on low zoom levels.
Can you provide any other information?
No response
Platforms Affected
Android, iOS, Windows, MacOS
Severity
Obtrusive: Prevents normal functioning but causes no errors in the console
Frequency
Consistently: Always occurs at the same time and location
Requirements
- [X] I agree to follow this project's Code of Conduct
- [X] My Flutter/Dart installation is unaltered, and
flutter doctor
finds no relevant issues - [X] I am using the latest stable version of this package
- [X] I have checked the FAQs section on the documentation website
- [X] I have checked for similar issues which may be duplicates
Hi there, and thanks for the report! We've known about this issue for a while, but have never tried to resolve it as it seems to be a rare-ish occurrence. Can you try splitting your line into two parts, where one starts/ends at 180 and the other at -180?
@JaffaKetchup Yeah splitting the lines was basically my workaround for this situation. I just think that looks weird though.
What would be really great is to have a map view, that has no physical boundaries left and right, basically like when you go on google maps and pan from one side to the other and the map just "rotates" in view
I've included two pictures of what I would consider expected behaviour for a map projection.
But thank you for your time and effort that went into this project!
.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Hi there @KKStudios, and sorry for the delay. I think someone else wanted infinitely panning maps, but that's quite a low priority. Can you send some pictures of how the splitting technique looks?
@JaffaKetchup Yeah splitting the lines was basically my workaround for this situation. I just think that looks weird though.
What would be really great is to have a map view, that has no physical boundaries left and right, basically like when you go on google maps and pan from one side to the other and the map just "rotates" in view
I've included two pictures of what I would consider expected behaviour for a map projection.
But thank you for your time and effort that went into this project!
![]()
.
Hi there @KKStudios,
I have the same problem,
Can you show your solution code?
Thx!
@JaffaKetchup
Here is how a workaround would look like splitting the path into two..
If you ask me, looks pretty crappy, that's why I won't implement that right now.
But probably would make a lot of work for the project to change to some kind of infinite scrolling map.
Cheers
@KKStudios Yeah, I can see that's less than desirable. There has been some talk on reworking the tile layer mechanics, and infinite functionality may be a part of this; but for now, it's unlikely we'll implement it. (Anyone else reading and wants to submit a PR, please do!)
Thanks for your insight :)
@zery6 Would be to much code to post right now since it's all integrated in my project and using internal utilities... But basically you just calculate where the great circle between two points crosse 180E/W.
Then you do polylines between that point and your departure/ destination point. Thats it.
Formula for calc can be found here: https://edwilliams.org/avform147.htm Very neat comprehension.
@JaffaKetchup Ok no problem. Maybe I'll have a look into it if modifying the project and digging into the codebase is worth the effort or implementing a scrolling map from scratch with only the required functionality is less work.
Just not my no1 priority right now.
Thanks anyhow.
If you felt brave, and wanted to have a play with a very alpha plugin, my vector slicer plugin can draw across lines across the dateline, and also repeat (but not infinite). Examples of the effect would be https://fluttermap.dabbles.info/dateline_test/#/ https://fluttermap.dabbles.info/geoslicer/#/ you should see the repeats if you zoom out (dateline crossing in first example, repeated none dateline stuff with simple clustering in 2nd).
Repo at https://github.com/ibrierley/geojson_vector_slicer Basically it's a fast way with functionality to draw geometry.
Couple of thoughts worth bearing in mind. It's designed for more static geometry (i.e it may take a few seconds if its very complicated, like the US example). But it may be ok redoing relatively simple geometry more often, I've not really tested that. Erm and it's very much a pre alpha :). But if someone else ever wanted a play, I'd probably work on it.
It's designed for geojson, but one could convert to geojson relatively quickly, I could probably add a method to do that.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Hi could you please inform is it bug will be solved at next release?
It's currently unlikely (unless someone wants to submit a PR).
I solved a similar issue in https://github.com/osmdroid/osmdroid, years ago.
If I remember well the idea is:
- to know the width of the world, in pixels
- to check each time we add a projected point - if I added/subtracted the world width, would I be closer to the previous polyline point?
- probably use the polyline center in order to decide which part of the world to center the polyline on
- possibly display as many identical polylines as the world replications need