This is a fix for issue #2432 Explore rapidly alternates between different maps.
The underlying problem is that on Android, the Explore map view is infinitely re-rendered. The onRegionChangeComplete callback should only be called at the end of a pan or zoom user interaction. On Android, it is also called when the map is first displayed, before any user interaction.
This seems to be a known issue, as there is a comment and a function in the codebase to handle it:
const handleRegionChangeComplete = async ( newRegion, boundaries ) => {
// Seems to be a bug in react-native-maps where
// onRegionChangeComplete fires once on initial load before the
// region actually changes, so we're just ignoring that update
// here
if ( Platform.OS === "android" && Math.round( newRegion.latitude ) === 0 ) {
return;
}
await updateMapBoundaries( newRegion, boundaries );
};
This code ignores the extra call for the initial map with latitude = longitude = 0°. It does not work for issue #2432 where the map is for a place with non-zero coordinates. An unintended consequence of this code is that it interferes with the correct behavior of the app when a user gets closer than 55.5km to the equator - the latitude can also be close to zero in user interactions.
This commit replaces this function with a different approach that directly tests whether the call is due to user interaction. This is the approach suggested in the react-native-maps documentation near the end of the document under "onRegionChangeComplete() callback is called infinitely".
This is a fix for issue #2432 Explore rapidly alternates between different maps.
The underlying problem is that on Android, the Explore map view is infinitely re-rendered. The
onRegionChangeComplete
callback should only be called at the end of a pan or zoom user interaction. On Android, it is also called when the map is first displayed, before any user interaction.This seems to be a known issue, as there is a comment and a function in the codebase to handle it:
This code ignores the extra call for the initial map with latitude = longitude = 0°. It does not work for issue #2432 where the map is for a place with non-zero coordinates. An unintended consequence of this code is that it interferes with the correct behavior of the app when a user gets closer than 55.5km to the equator - the latitude can also be close to zero in user interactions.
This commit replaces this function with a different approach that directly tests whether the call is due to user interaction. This is the approach suggested in the react-native-maps documentation near the end of the document under "onRegionChangeComplete() callback is called infinitely".