OwnWeb / flutter_map_tappable_polyline

A tappable Polyline plugin for flutter_map
https://pub.dev/packages/flutter_map_tappable_polyline
MIT License
54 stars 44 forks source link

Points on Tap? #39

Closed deezaster closed 2 years ago

deezaster commented 2 years ago

I need the points (coordinates), not only the position or the tag. Is this possible?

By the way, a very cool package!

tuarrep commented 2 years ago

I'm not sure to understand your needs.

Do you want to get the exact tap position on screen ?

deezaster commented 2 years ago

No, the tap position on screen i get it from the callback:

onTap: (polylines, tapPosition)

What i need are the points of the map: latitude and langitude.

tuarrep commented 2 years ago

Understood.

It's not possible currently but adding this don't seems to be too hard.

I'll try to hack something when I find some spare time if no one dit it before.

HugoHeneault commented 2 years ago

@deezaster I have a PR adding a MapController.pointToLatLng() method on flutter_map which has some issues but works until you rotate the map (it then become less accurate, I'm still trying to figure why)...

https://github.com/fleaflet/flutter_map/pull/1115

You can use our branch until it got merged, or even better, fork it on your own repo so you don't rely on something we could change later.

You could do something like:

onTap: (polylines, tapPosition) {
   final latLng = MapController.pointToLatLng(CustomPoint(tapPosition.localPosition.dx, tapPosition.localPosition.dy));
   print(latLng);
}
tuarrep commented 2 years ago

@HugoHeneault As the polyline detection is made, we should be able to find wich offset of the polyline is the nearest from the tap.

It's not as accurate as your PR but it's doable.

If OP needs the exact tap position in term of lat/long it's not an issue for this repo

HugoHeneault commented 2 years ago

@deezaster If it's fine on your side, you can close this issue. If you need more help, we're here.

Thanks!