Skip to content

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

Closed as not planned

Description

@S-Man42

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

Activity

  1. added
    needs triageThis new bug report needs reproducing and prioritizing
    on Nov 12, 2023
  2. JaffaKetchup commented on Nov 12, 2023

    @JaffaKetchup
    Member

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

  3. S-Man42 commented on Nov 12, 2023

    @S-Man42
    Author

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

  4. JaffaKetchup commented on Nov 12, 2023

    @JaffaKetchup
    Member

    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.

  5. S-Man42 commented on Nov 12, 2023

    @S-Man42
    Author

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

  6. JaffaKetchup commented on Nov 12, 2023

    @JaffaKetchup
    Member

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

  7. S-Man42 commented on Nov 12, 2023

    @S-Man42
    Author

    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.

  8. added
    needs triageThis new bug report needs reproducing and prioritizing
    P: 3 (low)(Default priority for feature requests)
    and removed
    needs triageThis new bug report needs reproducing and prioritizing
    on Dec 10, 2023
  9. changed the title [-][BUG] onPanUpdate event is not called on layer anymore[/-] [+][BUG] `onPanUpdate` event is not called on layer anymore[/+] on Dec 10, 2023
  10. linked a pull request that will close this issuemulti!: rewrite gesture handling #1733on Dec 14, 2023
  11. linked a pull request that will close this issuemulti!: rewrite gesture handling #1809on Jan 23, 2024
  12. 6 remaining items

  13. JaffaKetchup commented on May 24, 2024

    @JaffaKetchup
    Member

    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.

  14. changed the title [-][BUG] `onPanUpdate` event is not called on layer anymore[/-] [+][FEATURE] Revert to using single `onPanUpdate` to detect pan events[/+] on Aug 8, 2024
  15. Robbendebiene commented on Jan 19, 2026

    @Robbendebiene
    Contributor

    I ran into the same problem.
    It happens because the vertical/horizontal gesture recognizers take precedence over the pan recognizer on one dimensional drags.

    I solved it using a RawGestureDetector with a customPanGestureRecognizer that immediately declares victory:

    class EagerPanGestureRecognizer extends PanGestureRecognizer {
      @override
      void handleEvent(PointerEvent event) {
        // Immediately claim victory for this pointer
        if (event is PointerMoveEvent) resolve(GestureDisposition.accepted);
        super.handleEvent(event);
      }
    }
    // build
    
    final gestures = <Type, GestureRecognizerFactory>{};
    if(onDragStart != null || onDragUpdate != null || onDragEnd != null) {
      gestures[EagerPanGestureRecognizer] = GestureRecognizerFactoryWithHandlers<EagerPanGestureRecognizer>(
            EagerPanGestureRecognizer.new,
            (SingleEagerPanGestureRecognizer instance){
          instance.onStart = onDragStart;
          instance.onUpdate = onDragUpdate;
          instance.onEnd = onDragEnd;
        }
      );
    }
    return RawGestureDetector(
      gestures: gestures,
      child: child,
    );
  16. JaffaKetchup commented on Sep 3, 2026

    @JaffaKetchup
    Member

    Thanks again @Robbendebiene :)

    I've added your workaround to the documentation: https://docs.fleaflet.dev/layers/marker-layer#handling-gestures

  17. JaffaKetchup commented on Sep 3, 2026

    @JaffaKetchup
    Member

    Because there are no plans to change this at the moment, and a simple documented workaround is available, I'm going to close this.

    Only 3 years down the line - hope everyone in this thread is all good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions