is there a 'moveend' event handler like in Mapboxgl?
the current mapboxgl instance seems only register 'move' event.
moveend behave the same as move, which is not correct
Any solution to monitoring when the map is being dragged? Setting onLoad on InteractiveMap to register the event listeners move and moveend causes them to be fired at the same time so moveend is not useful to know when someone stopped dragging.
const onLoad = event => {
event.target.on('move', () => console.log('moving'));
event.target.on('moveend', () => console.log('stop'));
}
Based on mapbox examples https://www.mapbox.com/mapbox-gl-js/example/filter-features-within-map-view/ moveend is working fine. Is there workaround yet?
4.0.0's onViewportChange callback is invoked with a second argument including the following flags:
- inTransition
- isDragging
- isPanning
- isRotating
- isZooming
Thanks, it's solving the issue partially. I'd prefer to have explicit moveend / dragend indicating user interaction. ( usecase - fitBounds VS user interaction - both triggering onViewportChange but need different logic for every case )
At the moment partially solved it with custom rxjs debouncing.
@ilionic would you kindly share your solution of that rxjs debouncing?
I like to make a final call the API once I know at least there is a 1sec silence.
@layik using redux, just dispatching action (i.e. UPDATE_VIEWPORT) from React component with mapbox instance ( _updateViewport)
with redux-observable epics and rxjs6 it looks something like:
export const updateViewportEpic = (action$: Observable<Action>) =>
action$.pipe(
ofType('UPDATE_VIEWPORT'),
debounceTime(400),
switchMap(({ payload }) => {
// your logic here
// ...
This problem is still there. moveend behaves as move
The moveend behavior can be simulated by listening to onInteractionStateChange.
@Pessimistress that indeed did the job. Can confirm that this worked
onInteractionStateChange={(s) => {
if (
s.isDragging ||
s.inTransition ||
s.isRotating ||
s.isZooming ||
s.isHovering ||
s.isPanning
)
return;
// Perform your operation. In my case I update the URL.
updateURL(state.viewport as ViewportProps);
}}