Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] With Google Maps, zoomTapEnabled can't be modified and sometimes it's ignored. #5024

Closed
lucaslt89 opened this issue Apr 5, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@lucaslt89
Copy link

Summary

I found that the zoomTapEnabled prop in the MapView component can't be modified. If the map is rendered the first time with this prop in true/false, it doesn't matter what value we pass the following times, it always keep the first one. This causes that even when we pass this prop as false, the user can zoom in by double tapping on the map.

This makes it impossible to enable or disable the gesture if not when you create the map for the first time.

This only affects iOS using Google Maps

Reproducible sample code

import React, {useEffect, useState} from 'react';
import MapView from 'react-native-maps';

const App = () => {
  const [zoomEnabled, setZoomEnabled] = useState(false);

  useEffect(() => {
    setTimeout(() => {
      setZoomEnabled(true);
    }, 1000);
  }, []);

  return (
    <MapView provider="google" style={{flex: 1}} zoomTapEnabled={zoomEnabled} />
  );
};

export default App;

Steps to reproduce

Just the sample code is enough. The map is initially rendered with zoomTapEnabled={false} and a second later that changes to zoomTapEnabled={true} but the user still can't zoom in.

Expected result

The MapView component should enable or disable the zoom tap gesture as per the passed value.

Actual result

The MapView component only considers the value passed the first time.

React Native Maps Version

1.13.0

What platforms are you seeing the problem on?

iOS (Google Maps)

React Native Version

0.73.3

What version of Expo are you using?

Not using Expo

Device(s)

All iOS devices

Additional information

Looking at the native code I found the problem. I'll open a pull request but I wanted to have an issue to reference to.

In react-native-google-maps > AirGoogleMap.m file, there's a method called overrideGestureRecognizersForView which gets called when the map is loaded.

Sometimes this method is called before React Native sets the zoomTapEnabled prop to NO, and when this happens, the gesture recognizer with handleZoomTapGesture action is not removed. The next time overrideGestureRecognizersForView is called, the origGestureRecognizersMeta dict already contains all the gestures so it just continue without making any changes.

I think instead of removing the gesture, we should enable/disable it when the zoomTapEnabled property is set.

@lucaslt89 lucaslt89 added the bug Something isn't working label Apr 5, 2024
lucaslt89 pushed a commit to lucaslt89/react-native-maps that referenced this issue Apr 5, 2024
See the issue for a test example and the issue details

Closes issue react-native-maps#5024
@lucaslt89 lucaslt89 mentioned this issue Apr 5, 2024
lucaslt89 pushed a commit to lucaslt89/react-native-maps that referenced this issue Apr 5, 2024
See the issue for a test example and the issue details

Closes issue react-native-maps#5024
@lucaslt89
Copy link
Author

hghag I opened this PR again since the issue still persist. Can you review it and provide a review pls?

@salah-ghanim
Copy link
Collaborator

@lucaslt89 should be fixed in v1.15.2, please feel free to reopen if not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants