mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

Can I have access to events like onMoveEnd?

Open AnEpicName opened this issue 2 years ago • 6 comments

I need to update the data on my map if it possible at the end of, for example, the camera movement, to avoid getting too much data from my API. I've already done this in web by using onDragEnd but I can't find a simple way to do this in this plugin. I basically need something like these Events, or the equivalent for the camera position.

Is there a way to do this? I found mapboxMap.addListener() but I'm not sure about how it works and if it can listen to those events.

AnEpicName avatar Jan 13 '23 14:01 AnEpicName

I think you can do it with below code in latest version.

MapWidget (
  onMapIdleListener :  (mapIdleEventData) {
      // any function
  }
)

gtsl-2 avatar Feb 22 '23 03:02 gtsl-2

I think you can do it with below code in latest version.

MapWidget (
  onMapIdleListener :  (mapIdleEventData) {
      // any function
  }
)

keep in mind that onMapIdleListener returns when the map is idle so when the map is loaded for the first time it will take some seconds to fire. Then when the scroll ends it will fire pretty fast.

AlbertoNoris avatar Jun 24 '23 21:06 AlbertoNoris

Currently has a bug on Android devices that not trigger onMapIdleListener when move camera

The README says that listening for events is supported, but it doesn't seem like so. I also need to be able to listen for events like touchstart, but I can't find a way to do it. Hopefully someone from Mapbox will help us.

emmanuelvr avatar Jan 22 '24 14:01 emmanuelvr

I managed to implement a similar functionality by wrapping the MapWidget in a GestureDetector and using the coordinateForPixel method.

emmanuelvr avatar Jan 22 '24 16:01 emmanuelvr

I managed to implement a similar functionality by wrapping the MapWidget in a GestureDetector and using the coordinateForPixel method.

can you sure sample code of how you implemented it?

sKY02644 avatar Jan 22 '24 16:01 sKY02644