Skip to content

Commit fcf3e7a

Browse files
sameerzohyCyanid0
authored andcommitted
[feat]: returning vehicle number in the map click event
1 parent 3c83fd9 commit fcf3e7a

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

android/src/main/java/com/rnmaps/maps/MapView.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,16 +505,17 @@ public boolean onMarkerClick(@NonNull Marker marker) {
505505
} else {
506506
// Handle native markers added via updateNearbyMarkersFromProcessedData
507507
Object tag = marker.getTag();
508-
String id = null;
508+
String routeCode = null;
509509
String action = "marker-press";
510510
String actionType = null;
511511
boolean isPressFeedbackEnabled = false;
512+
String id = null;
512513

513514
if (tag instanceof java.util.Map) {
514515
java.util.Map tagMap = (java.util.Map) tag;
515-
Object idObj = tagMap.get("id");
516-
if (idObj instanceof String) {
517-
id = (String) idObj;
516+
Object routeCodeObj = tagMap.get("routeCode");
517+
if (routeCodeObj instanceof String) {
518+
routeCode = (String) routeCodeObj;
518519
}
519520
Object actionObj = tagMap.get("action");
520521
if (actionObj instanceof String) {
@@ -528,6 +529,10 @@ public boolean onMarkerClick(@NonNull Marker marker) {
528529
if (isPressFeedbackEnabledObj instanceof Boolean) {
529530
isPressFeedbackEnabled = (Boolean) isPressFeedbackEnabledObj;
530531
}
532+
Object idObj = tagMap.get("id");
533+
if (idObj instanceof String) {
534+
id = (String) idObj;
535+
}
531536
}
532537

533538
if (id != null) {
@@ -537,6 +542,7 @@ public boolean onMarkerClick(@NonNull Marker marker) {
537542
WritableMap mapEventData = makeClickEventData(marker.getPosition());
538543
mapEventData.putString("action", "marker-press");
539544
mapEventData.putString("actionType", actionType);
545+
mapEventData.putString("routeCode", routeCode);
540546
mapEventData.putString("id", id);
541547

542548
dispatchEvent(mapEventData, OnMarkerPressEvent::new);
@@ -2274,10 +2280,11 @@ public void onAnimationEnd(Animator animation) {
22742280
if (newMarker != null) {
22752281
if(!isCluster && !routeCode.isEmpty()) {
22762282
java.util.Map<String, Object> tagMap = new java.util.HashMap<>();
2277-
tagMap.put("id", routeCode);
2283+
tagMap.put("routeCode", routeCode);
22782284
tagMap.put("action", "marker-press");
22792285
tagMap.put("actionType", action);
22802286
tagMap.put("isPressFeedbackEnabled", isPressFeedbackEnabled);
2287+
tagMap.put("id", driverId);
22812288
newMarker.setTag(tagMap);
22822289
}
22832290
nearbyMarkersCache.put(driverId, newMarker);

dist/src/sharedTypes.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export type MarkerPressEvent = NativeSyntheticEvent<{
7474
id: string;
7575
action: 'marker-press';
7676
actionType?: string;
77-
77+
routeCode?: string;
7878
coordinate: LatLng;
7979
/**
8080
* @platform Android

src/sharedTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export type MarkerPressEvent = NativeSyntheticEvent<{
9393
id: string;
9494
action: 'marker-press';
9595
actionType?: string;
96+
routeCode?: string;
9697
coordinate: LatLng;
9798

9899
/**

0 commit comments

Comments
 (0)