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

feat(AIRGoogleMapsMarker): add onSelect/onDeselect support fo google maps #4990

Merged

Conversation

jan-kozinski
Copy link
Collaborator

@jan-kozinski jan-kozinski commented Mar 3, 2024

Does any other open PR do the same thing?

no

What issue is this PR fixing?

#4970

#114

How did you test this PR?

andoid emulator & ios simulator

@jan-kozinski jan-kozinski marked this pull request as ready for review March 10, 2024 16:29
@jan-kozinski jan-kozinski changed the title feat(AIRGoogleMapsMarker): add onSelect/onDeselct support fo google maps feat(AIRGoogleMapsMarker): add onSelect/onDeselect support fo google maps Mar 10, 2024
@EJohnF
Copy link

EJohnF commented Mar 10, 2024

Wow! i was looking for this functionality, and you just pushed it 🎉

Copy link
Collaborator

@mateki0 mateki0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and works fine on iOS simulator and Android device. I'm just thinking if second press on the same marker shouldn't be considered as deselect on iOS. It works like that on Android though.

@jan-kozinski
Copy link
Collaborator Author

jan-kozinski commented Mar 11, 2024

Thanks @mateki0 good catch! I've tweaked the google maps implementation to match the mapkit one's. The mapkit implementation is the original one and is implemented by mapkit itself. So no it should be impossible to deselect a marker by clicking on it multiple times. Also I've added the onMarkerSelect and onMarkerDeselect functionality since its related

@salah-ghanim
Copy link
Collaborator

@jan-kozinski the code looks good, but I have a small feedback

I wouldn't change the AIRGoogleMapMarker.m eventFromMarker AIRGMSMarker.m for some reason that class was left empty all the history of the repo, I would simply keep the same tradition.

instead just modify the function in AIRGoogleMapMarker to accept action as a parameter, for example:

eventFromMarker: marker action:(_Nullable NSString *) action {
}

finally, In general I would avoid adding anything to the .h files, because that implies new public interfaces / functionality ... I don't see the need for such APIs most of the time, rather the body of a class (.m file) can manage the state internally and propagate the events correctly as you can see.

@jan-kozinski
Copy link
Collaborator Author

jan-kozinski commented Mar 23, 2024

Hi @salah-ghanim thanks for the feedback. I've added the makeEventData to the AIRGMSMarker, because selectedMarker in AIRGoogleMap must ba an instance of GSMMarker (it can't be a AIRGoogleMapMarker because the super setSelectedMarker expects a AIRGMSMarker.
Still, I wanted both classes to use the same method for event generating as to avoid incosistent marker events in future.
EDIT:
found out it is actually possible to get the instance of AIRGoogleMapMarker through fakeMarker property of AIRGMSMarker, so I'm moving the implementation to AIRGoogleMapMarker as suggested

@jan-kozinski
Copy link
Collaborator Author

jan-kozinski commented Mar 23, 2024

Also thanks for the advice with .h files, I've removed as many public interfaces as possible. Removing them further causes the code to not compile, so you can take a second look when you got time @salah-ghanim .

@salah-ghanim salah-ghanim merged commit b9fbe31 into react-native-maps:master Mar 29, 2024
4 checks passed
react-native-maps-bot pushed a commit that referenced this pull request Mar 29, 2024
# [1.12.0](v1.11.3...v1.12.0) (2024-03-29)

### Features

* **google-maps:** add onSelect/onDeselect support fo google maps ([#4990](#4990)) ([b9fbe31](b9fbe31))
@react-native-maps-bot
Copy link
Collaborator

🎉 This PR is included in version 1.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Super-CodeKing added a commit to Super-CodeKing/react_native_map that referenced this pull request Apr 26, 2024
# [1.12.0](react-native-maps/react-native-maps@v1.11.3...v1.12.0) (2024-03-29)

### Features

* **google-maps:** add onSelect/onDeselect support fo google maps ([#4990](react-native-maps/react-native-maps#4990)) ([b9fbe31](react-native-maps/react-native-maps@b9fbe31))
fairskyDev0201 pushed a commit to fairskyDev0201/react-native-maps that referenced this pull request Apr 29, 2024
# [1.12.0](react-native-maps/react-native-maps@v1.11.3...v1.12.0) (2024-03-29)

### Features

* **google-maps:** add onSelect/onDeselect support fo google maps ([#4990](react-native-maps/react-native-maps#4990)) ([b9fbe31](react-native-maps/react-native-maps@b9fbe31))
DavidLee0501 added a commit to DavidLee0501/React-Native-Map that referenced this pull request Aug 12, 2024
# [1.12.0](react-native-maps/react-native-maps@v1.11.3...v1.12.0) (2024-03-29)

### Features

* **google-maps:** add onSelect/onDeselect support fo google maps ([#4990](react-native-maps/react-native-maps#4990)) ([b9fbe31](react-native-maps/react-native-maps@b9fbe31))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants