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.73k stars 860 forks source link

[FEATURE] Revert to using single `onPanUpdate` to detect pan events #1729

Open S-Man42 opened 10 months ago

S-Man42 commented 10 months ago

What is the bug?

Since v4 I was able to create a marker which contained a GestureDetector as builder output. This GestureDetector included an onPanUpdate event which I used to enable dragging functionality. It worked fine a long time.

Now I upgraded FlutterMap to v5 and it came out, that exactly this event is not called anymore. Funny: All other events can be called as onTap or even onVerticalDragUpdate.

Do you have an idea what changed and how could I restore this feature?

How can we reproduce it?

FlutterMap(
    children: [
        MarkerLayer(
         markers: [      
            Marker(
              point: myPoint,
              builder: (context) => GestureDetector(
                onTap: () {
                    // WORKS
                },
                onPanUpdate: (details) {
                    // DOES NOT WORK ANYMORE
                },
                child: myIcon
              )
            )
         ]
        )
    ]
)

Do you have a potential solution?

No response

Platforms

Android, web, iOS

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console

JaffaKetchup commented 10 months ago

Hi @S-Man42, Can you try disabling MapOptions.applyPointerTranslucencyToLayers to see if that makes a difference?

S-Man42 commented 10 months ago

This is not part of v5 as I see it. I believe it was integrated a bit later... But I cannot do another major upgrade at the moment. I need a v5 solution, if possible...

JaffaKetchup commented 10 months ago

Ah, sorry, didn't see that you were still using v5. Can I ask why you are not using the flutter_map_dragmarker plugin? If there's a reason, maybe you can check the implementation there?

The only thing I can think of off the top of my head as to why this changed is due to #1455, but that should have been available in and impacting v4 as well.

S-Man42 commented 10 months ago

The only thing I can think of off the top of my head as to why this changed is due to #1455, but that should have been available in and impacting v4 as well.

Yes, you are right, I cross-checked: We were using v3.1.0, not 4 - sorry my fault.

Can I ask why you are not using the flutter_map_dragmarker plugin

I am currently trying. But my problem is, that I am using the flutter_map_marker_popup plugin for my markers. So I cannot see a way to combine both plugins to create a draggable popup marker. I am currently trying to implement an inherited PopupMarkerLayer with integrated code from the DragMarker plugin, but it seems not correct to me:

Using one third-party lib code (DragMarker) to enhance a second third-party lib (PopupMarker) just to fix an issue of a third plugin (FlutterMap itself) whilst previously everything was fine...

JaffaKetchup commented 10 months ago

Ok, can you try what that PR recommends to fix the issue then and listen to onVerticalDrag and onHorizontalDrag separately?

S-Man42 commented 10 months ago

Yes, I can listen to these events successfully. But the events do not what I want to, since they give me only delta x or delta y. So my markers will only be moved directly up/down or left/right.

Yes, I could implement some workaround logic to recalculate the correct direction as the DragMarker plugin does.

But do you really believe, that this is the smartest way? Using two independent events (plus need to store some start positions for the opposite directions, so in fact I need at least 4 events) which are not designed for this issues (as there are designed for one-directional issues as scrollbars or similar) to write some logic by manually detecting the touch point/cursor position and recalculate some behaviour which originally yet existed with onPanUpdate?

I mean, pls have a look at the DragMarker plugin's code. This all is required to get this workaround running for something which already worked out-of-the-box.

Mike-3 commented 4 months ago

Is there any progress? The problem is that flutter_map 3.1 is no longer compatible with the current Flutter. But we cannot update flutter_map to the current version because the touch events no longer work properly. There are no more status changes/progress in the corresponding PR.

JaffaKetchup commented 4 months ago

Ok, can you try what that PR recommends to fix the issue then and listen to onVerticalDrag and onHorizontalDrag separately?

Have you tried this?

S-Man42 commented 4 months ago

Yes, we did (see my post above). But we did not came up with any proper solution, so we had do downgrade. We hoped very much for the upcoming changes and the PR...

JaffaKetchup commented 4 months ago

Unfortunately that PR is likely to take a little longer than planned. We're still considering the best way forward. There's also a good chance that that PR won't fix the issue. For now I believe this is the only way.

The flutter_map_dragmarker doesn't seem to be that complex, it seems to just redirect both to the same listener methods. Is there any reason this doesn't work for you?

https://github.com/ibrierley/flutter_map_dragmarker/blob/1e79d6bc9c9f3757d68545b24e15c99323c49ab2/lib/src/drag_marker_widget.dart#L64-L69 https://github.com/ibrierley/flutter_map_dragmarker/blob/1e79d6bc9c9f3757d68545b24e15c99323c49ab2/lib/src/drag_marker_widget.dart#L127-L130

S-Man42 commented 4 months ago

Hi, I am not quite sure, but you are pointing me to the Dragmarker plugin as at beginning of this thread, right? So please read thr discussion:

  1. I cannot use this plugin out-of-the-box because I need to combine it with the Popup Marker Plugin.
  2. As stated above: It is not quite clear to me, why there is a need for listen to at least four different events, that a not even designed for this purpose, write an own logic, just do calculate the drag data I got directly in one single event until version 3.x. Wouldn't it be much easier and even more correct to simply return the x/y values in the onPanUpdate as you did before instead of require us to write some logic on our own?
JaffaKetchup commented 4 months ago

I'm not saying to use that plugin, I'm just saying it doesn't appear to be too hard to implement. Please see #1455 to find out why the onPanUpdate was removed. At the moment, there is no short term plan to add this back, so if you require it, you'll need to use this workaround.