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

MapMarker onSelect does not fire with Google Maps on iOS #5037

Closed
sameerxanand opened this issue Apr 19, 2024 · 1 comment
Closed

MapMarker onSelect does not fire with Google Maps on iOS #5037

sameerxanand opened this issue Apr 19, 2024 · 1 comment
Labels
bug Something isn't working released

Comments

@sameerxanand
Copy link

Summary

This implementation deployed in v1.12.0 is not working when using Google Maps on iOS.

Per the JSDoc:

/**
 * Callback that is called when the marker becomes selected.
 * This will be called when the callout for that marker is about to be shown.
 *
 * @platform iOS: Supported.
 * @platform Android: Supported
 */
onSelect?: (event: MarkerSelectEvent) => void;

Reproducible sample code

import MapView, { Marker, PROVIDER_GOOGLE } from "react-native-maps";
import { useState } from "react";

const mapAnnotations = [
  {
    latitude: 40.74063557912163,
    longitude: -73.99162665798178,
    title: "Test",
  },
]

const NEW_YORK_REGION = {
  latitude: 40.733748,
  longitude: -73.960588,
  latitudeDelta: 0.001,
  longitudeDelta: 0.1,
};

export default function App() {
  const [initialRegion, setInitialRegion] = useState(NEW_YORK_REGION);

  return (
    <MapView
      className="w-full h-full"
      provider={PROVIDER_GOOGLE}
      showsUserLocation
      followsUserLocation
      region={initialRegion}
    >
      {mapAnnotations.map((annotation) => (
        <Marker
          key={`${annotation.latitude}, ${annotation.longitude}`}
          coordinate={{
            latitude: annotation.latitude,
            longitude: annotation.longitude,
          }}
          title={annotation.title}
          onSelect={(e) => console.log(e)}
          onDeselect={(e) => console.log(e)}
        />
      ))}
    </MapView>
  )
}

Steps to reproduce

Select the map marker with title "Test" at coordinate 40.74063557912163, -73.99162665798178

Expected result

The console should log the event

Actual result

Console doesn't log anything

React Native Maps Version

1.14.0

What platforms are you seeing the problem on?

iOS (Google Maps)

React Native Version

0.73.6

What version of Expo are you using?

SDK 48

Device(s)

iPhone 15

Additional information

I am using Expo SDK 50. The dropdown option doesn't let me select past 48.

@sameerxanand sameerxanand added the bug Something isn't working label Apr 19, 2024
@mateki0
Copy link
Collaborator

mateki0 commented Apr 23, 2024

Hi, @sameerxanand are you sure that you have newest version of react-native-maps? Maybe you should try to clean cache
with one of those commands? https://docs.expo.dev/troubleshooting/clear-cache-macos-linux/
When I tried to reproduce this bug for the first time I had the same problem, but building on another simulator fixed it for me so I'm pretty sure that it's something with expo caching :)

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

No branches or pull requests

3 participants