flutter-maplibre-gl icon indicating copy to clipboard operation
flutter-maplibre-gl copied to clipboard

Adding events to the map

Open noorbakerally opened this issue 2 years ago • 4 comments

Like it is in the JavaScript version, is it possible to attach events to the map? For example like the MouseTouchEvent, more specifically touchend.

map.on('touchend', (e) => {
console.log(e);
}

My exact use case is that I need to trigger a method when a long press ends.

noorbakerally avatar Aug 15 '22 08:08 noorbakerally

Yes, you can specify different event callbacks in the MaplibreMap constructor, e.g. onMapLongClick

m0nac0 avatar Aug 15 '22 12:08 m0nac0

Yes, this I got it, I'm already using onMapLongClick, but my question is can we raise an event when the long map click ends?

noorbakerally avatar Aug 15 '22 13:08 noorbakerally

I am using the native Flutter Listener widget for this with the child being an instance of the MaplibreMap. Then, I am using the onPointerUp callback in the Listener widget to capture when the longpress ends. The issue is that onPointerUp will be called everytime the pointer is up, so even for simple clicks on the instance of the MaplibreMap. So having to keep boolean to know whether it's a longpress that is ending.

I hope it's the right way of doing.

noorbakerally avatar Aug 15 '22 22:08 noorbakerally

can we raise an event when the long map click ends?

When is the long click event raised for you? During the long click? I unfortunately think its not possible to change this in the native SDK we're using.

m0nac0 avatar Aug 20 '22 14:08 m0nac0

Closing this question since there hasn't been any response in a long time.

josxha avatar May 28 '24 07:05 josxha