react-native-maps
react-native-maps copied to clipboard
details.isGesture undefined in onRegionChange() callback when map is dragged (iOS)
Summary
The <MapView /> onRegionChange() callback details argument has undefined isGesture value when dragging the map.
This is contained in the second argument of the onRegionChange callback, i.e. :
onRegionChange={(region, details) => { console.log(details.isGesture) }
Reproducible sample code
import React from 'react';
import {
Dimensions,
StatusBar,
StyleSheet,
View,
} from 'react-native';
import MapView, {PROVIDER_GOOGLE} from 'react-native-maps';
const screenDimensions = Dimensions.get('screen');
return (
<View style={styles.container}>
<StatusBar />
<View style={styles.mapContainer}>
<MapView
onRegionChange={(region, details) => {
console.log('onRegionChange...');
console.log({details});
}}
provider={PROVIDER_GOOGLE}
style={styles.map}
region={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.015,
longitudeDelta: 0.0121,
}}
/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1,
},
mapContainer: {
...StyleSheet.absoluteFillObject,
height: screenDimensions.height,
width: screenDimensions.width,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
...StyleSheet.absoluteFillObject,
backgroundColor: 'yellow',
},
});
export default App;
Steps to reproduce
Drag the map from the following example above. Check the logs and notice that details.isGesture is always undefined.
Expected result
When dragging the map, the details.isGesture value should be true. When the map is returned to a set of coordinates (i.e. when using fitToCoordinates, the details.isGesture value should be false.
Actual result
When dragging the map, and when using fitToCoordinates, details.isGesture is always undefined.
React Native Maps Version
1.23.5
What platforms are you seeing the problem on?
iOS (Google Maps)
React Native Version
0.79.2
What version of Expo are you using?
Not using Expo
Device(s)
iPhone 12 mini
Additional information
No response
@salah-ghanim This is still supported with the new architecture correct? I'm seeing the same behavior with the latest version and am using Expo 53.
@trooperandz Have you been able to solve this? I've been able to use an AI agent to get a patch working for Android, but I'm still not having any luck on iOS.
@iM-GeeKy I have not been able to solve this yet. For context, the onRegionChange() handler was not working at all (no gestures registering whatsoever) until a recent fix which was deployed last week. However, upon testing this and confirming that onRegionChange() was now registering user drags on the map (after the fix), I noticed that details.isGesture was always undefined.
@trooperandz Okay thanks for the update, I'm seeing the same behavior too on iOS with provider google except with onRegionChangeComplete and as previously mentioned was able to get the android side of it working with a temporary patch and I'll keep trying with iOS until we get a fix.
One update on this; I see that Android details.isGesture is now working on Android (react-native-maps version 1.23.8), but it is still always undefined on iOS however.
Yeah, I'm noticing the isGesture isn't making it into the generated code, partially explains why it's always undefined. I've managed to get it working with a patch, but I'm still regression testing it.
+1 (version 1.28.3) react-native 0.79.1 react 19.0.0
Same, android looks ok, but iOS is not working, still undefined. Any workaround?
Also seeing this on expo 53.
And onRegionChangeStart is supposed to be of type (e:NativeSyntheticEvent<Details>)=>void but the actual event argument has a different shape.
When I log e.nativeEvent I get:
{
"region": {
"latitude": 0,
"longitude": 0,
"latitudeDelta": 0,
"longitudeDelta": 0
},
"continuous": false,
"target": 36
}
Same issue on iOS
Same here, iOS only, using expo.
:tada: This issue has been resolved in version 1.24.6 :tada:
The release is available on:
Your semantic-release bot :package::rocket: