rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.27k stars 849 forks source link

[Bug]: (Android only) onMapIdle (etc) does not trigger with a native UserLocation #2902

Open savv opened 1 year ago

savv commented 1 year ago

Mapbox Implementation

Mapbox

Mapbox Version

10.7.0

Platform

Android

@rnmapbox/maps version

10.0.7

Standalone component to reproduce

In the MapHandlers example, add the following line inside of the MapView:

<UserLocation key="mapbox-location" showsUserHeadingIndicator renderMode={UserLocationRenderMode?.Native} />

Observed behavior and steps to reproduce

Observe that onMapIdle does not get called anymore.

Expected behavior

Should still get called.

Notes / preliminary analysis

No response

Additional links and references

No response

trungledangAxonActive commented 1 year ago

I also got this issue

mfazekas commented 1 year ago

What is the use case for onMapIdle?

It seems that the pulsing is useLocation prevents the map renderer from going to idle, so onMapIdle will not be called.

https://github.com/mapbox/mapbox-maps-android/issues/2116

savv commented 1 year ago

Effectively, we wanted to use it as a replacement for onRegionDidChange. One use case is to capture and store the latest viewport that the user panned to.

It looks like onMapIdle has a more render-focused meaning. However, I'm not sure how to achieve this right now with v10. Maybe the wrapper needs some camera lifecycle callbacks?

mfazekas commented 1 year ago

@savv thanks much, they suggest adding camera animation observers for that purpose. I'll try to implement that and we'll see if that meets your use case.

You're right that onMapIdle is not a replacement for onRegionDidChange

kassemitani commented 1 year ago

We have the same issue, onMapIdle is not being triggered on Android. While onCameraChanged is being triggered both iOS & Android.

mfazekas commented 1 year ago

For now the workaround is to use debounce onCameraChanged. That should be called when map stopped changing for a while

kesteer commented 1 year ago

@mfazekas

You're right that onMapIdle is not a replacement for onRegionDidChange

Do you think we should change the function jsdoc in the MapView.tsx file related to onMapIdle as it currently says it IS a replacement and is probably leading to a bit of confusion.

v10 only, replaces onRegionDidChange

And also in the console warning.

https://github.com/rnmapbox/maps/blob/27ab1262681bff09b509661b9fec670375fc1c71/src/components/MapView.tsx#L540-L542

If you think its a good idea I can pop in a PR for it.

mfazekas commented 11 months ago

Valid bug, but not planned do to lack of resources. Closing as not planned.

I don't think this is to be fixed, but would be nice to provide some solution for the use case.

savv commented 11 months ago

Given that this is a bug and not a feature request, it would make sense to me to keep it open. That way, people facing the same issue can find it more easily; and maybe even fix it (or at least update the docs, as somebody already suggested).

davor-bauk-sh commented 6 months ago

I'm also experiencing this on iOS. Neither onMapIdle nor onRegionDidChange get called when LocationPuck's pulsing.isEnabled property is true.