flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

[BUG] Crossing W/E Extremity With `Polyline` Results In Unexpected Lines

Open WorldpixelSoftware opened this issue 1 year ago • 16 comments

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.

flutter_map_bug

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

WorldpixelSoftware avatar Aug 11 '22 23:08 WorldpixelSoftware

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 avatar Aug 16 '22 20:08 JaffaKetchup

@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!

maps_ew_crossing gcmapper_ew_crossing .

WorldpixelSoftware avatar Aug 18 '22 17:08 WorldpixelSoftware

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.

github-actions[bot] avatar Sep 18 '22 02:09 github-actions[bot]

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 avatar Sep 18 '22 06:09 JaffaKetchup

@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!

maps_ew_crossing gcmapper_ew_crossing .

Hi there @KKStudios,
I have the same problem, Can you show your solution code? Thx!

zery6 avatar Sep 26 '22 01:09 zery6

@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.

180_crossing

But probably would make a lot of work for the project to change to some kind of infinite scrolling map.

Cheers

WorldpixelSoftware avatar Sep 26 '22 20:09 WorldpixelSoftware

@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 :)

JaffaKetchup avatar Sep 26 '22 20:09 JaffaKetchup

@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.

WorldpixelSoftware avatar Sep 26 '22 20:09 WorldpixelSoftware

@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.

WorldpixelSoftware avatar Sep 26 '22 20:09 WorldpixelSoftware

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.

ibrierley avatar Sep 26 '22 22:09 ibrierley

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.

github-actions[bot] avatar Oct 27 '22 02:10 github-actions[bot]

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.

github-actions[bot] avatar Nov 27 '22 02:11 github-actions[bot]

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.

github-actions[bot] avatar Dec 28 '22 01:12 github-actions[bot]

Hi could you please inform is it bug will be solved at next release?

ivanzhadnov avatar Feb 24 '23 02:02 ivanzhadnov

It's currently unlikely (unless someone wants to submit a PR).

ibrierley avatar Feb 24 '23 07:02 ibrierley

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

monsieurtanuki avatar Apr 10 '24 12:04 monsieurtanuki