react-native-maps icon indicating copy to clipboard operation
react-native-maps copied to clipboard

details.isGesture undefined in onRegionChange() callback when map is dragged (iOS)

Open trooperandz opened this issue 7 months ago • 10 comments

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

trooperandz avatar May 06 '25 16:05 trooperandz

@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.

iM-GeeKy avatar May 10 '25 11:05 iM-GeeKy

@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 avatar May 13 '25 22:05 iM-GeeKy

@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 avatar May 14 '25 06:05 trooperandz

@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.

iM-GeeKy avatar May 14 '25 09:05 iM-GeeKy

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.

trooperandz avatar May 15 '25 18:05 trooperandz

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.

iM-GeeKy avatar May 15 '25 18:05 iM-GeeKy

+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?

bobanminic96 avatar May 16 '25 09:05 bobanminic96

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
}

trevor-coleman avatar May 16 '25 19:05 trevor-coleman

Same issue on iOS

mikemonaco avatar Jun 10 '25 16:06 mikemonaco

Same here, iOS only, using expo.

elyobo avatar Jun 17 '25 03:06 elyobo

:tada: This issue has been resolved in version 1.24.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

react-native-maps-bot avatar Jul 18 '25 11:07 react-native-maps-bot