From 1c461becf544837cb6ecc20d435125b017a248ec Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Fri, 1 Nov 2024 18:31:23 +0200 Subject: [PATCH] fix: onMarkerClick and onMarkerInfoWindowTapped on Android (#322) --- .../google/android/react/navsdk/MapViewFragment.java | 4 ++-- .../google/android/react/navsdk/NavViewFragment.java | 4 ++-- example/src/App.tsx | 10 ++++++++-- example/src/screens/NavigationScreen.tsx | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/google/android/react/navsdk/MapViewFragment.java b/android/src/main/java/com/google/android/react/navsdk/MapViewFragment.java index 1cb60d6..ff10af9 100644 --- a/android/src/main/java/com/google/android/react/navsdk/MapViewFragment.java +++ b/android/src/main/java/com/google/android/react/navsdk/MapViewFragment.java @@ -113,7 +113,7 @@ public void onRecenterButtonClick() { @Override public void onMarkerClick(Marker marker) { - emitEvent("onMapReady", ObjectTranslationUtil.getMapFromMarker(marker)); + emitEvent("onMarkerClick", ObjectTranslationUtil.getMapFromMarker(marker)); } @Override @@ -138,7 +138,7 @@ public void onGroundOverlayClick(GroundOverlay groundOverlay) { @Override public void onMarkerInfoWindowTapped(Marker marker) { - emitEvent("onInfoWindowClick", ObjectTranslationUtil.getMapFromMarker(marker)); + emitEvent("onMarkerInfoWindowTapped", ObjectTranslationUtil.getMapFromMarker(marker)); } @Override diff --git a/android/src/main/java/com/google/android/react/navsdk/NavViewFragment.java b/android/src/main/java/com/google/android/react/navsdk/NavViewFragment.java index a1e7bc6..57ad854 100644 --- a/android/src/main/java/com/google/android/react/navsdk/NavViewFragment.java +++ b/android/src/main/java/com/google/android/react/navsdk/NavViewFragment.java @@ -125,7 +125,7 @@ public void onRecenterButtonClick() { @Override public void onMarkerClick(Marker marker) { - emitEvent("onMapReady", ObjectTranslationUtil.getMapFromMarker(marker)); + emitEvent("onMarkerClick", ObjectTranslationUtil.getMapFromMarker(marker)); } @Override @@ -150,7 +150,7 @@ public void onGroundOverlayClick(GroundOverlay groundOverlay) { @Override public void onMarkerInfoWindowTapped(Marker marker) { - emitEvent("onInfoWindowClick", ObjectTranslationUtil.getMapFromMarker(marker)); + emitEvent("onMarkerInfoWindowTapped", ObjectTranslationUtil.getMapFromMarker(marker)); } @Override diff --git a/example/src/App.tsx b/example/src/App.tsx index 4fa77ab..b9afe05 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -17,6 +17,7 @@ import * as React from 'react'; import { NavigationContainer, + useIsFocused, useNavigation, type NavigationProp, } from '@react-navigation/native'; @@ -37,15 +38,20 @@ export type StackNavigation = NavigationProp; const HomeScreen = () => { const { navigate } = useNavigation(); + const isFocused = useIsFocused(); + return ( -