fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.76k stars 860 forks source link

Polyline projection on a globe #746

Closed goranskular closed 3 years ago

goranskular commented 4 years ago

Hi, it would be great if polylines were projected on the globe. Now polyline is a straight line from one latlng to a second one. It is ok for greater zoom levels, but very inaccurate when zoomed out.

Is it possible that we get projected polylines?

ibrierley commented 4 years ago

Do you mean the points are out, or you want the line to be a curve to account for it, screenshot may be useful.

goranskular commented 4 years ago

Yes, I mean a projected curved line like this: image

goranskular commented 4 years ago

this geodesic: true would be perfect (snippet from google_maps_flutter):

Polyline(
          polylineId: PolylineId(
              'uniqueid'),
          geodesic: true,
          points: [originLatLng, destinationLatLng],
          width: 3,
          color: Theme.of(context).primaryColor,
        )
maRci002 commented 4 years ago

Can u upload flutter_map image version which is now incorrect?

goranskular commented 4 years ago

Incorrect Polyline(LatLng A, LatLng B): image

Correct Polyline(LatLngA,...... much more points on bearing to B, LatLng B): image

p.s. I made the correct one myself with a method that generates XY points on a route from point A to point B.. so polyline is not with two points: [LatLng A, LatLng B], but with XY points: [LatLng A, LatLngXY1,....LatLngB]

maRci002 commented 4 years ago

Nice workaround.

goranskular commented 4 years ago

I encountered a new problem, but I already saw some issues about it :) So, this approach is not so simple.

image

S-Man42 commented 4 years ago

I am using a similar solution in my app for nearly a year right now:

Drawing Geodetic Polyline.: https://github.com/S-Man42/GCWizard/blob/master/lib/widgets/tools/coords/base/gcw_map_geometries.dart#L39

I am splitting the real way into several substeps, project from start to all substeps and then I draw a polyline. The same algorithm can be used for drawing better circles keeping their radius on the projected map:

Drawing "Geodetic" Circles : https://github.com/S-Man42/GCWizard/blob/master/lib/widgets/tools/coords/base/gcw_map_geometries.dart#L81

grafik

Surely, it's not the most efficient way to do this, espessially for more general purposes. But if you like, feel free to use the code.

The problem with the... I call it overflow..., I reported this already some months ago. I would be glad to see this problem solved! https://github.com/fleaflet/flutter_map/issues/630

Maybe this could be a solution? https://github.com/fleaflet/flutter_map/issues/468

github-actions[bot] commented 3 years ago

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] commented 3 years ago

This issue was closed because it has been stalled for 5 days with no activity.