Skip to content

Commit 0dd7a37

Browse files
gag0712trevor-yangmym0404
authored
fix: ios 마커 onTap 이벤트 동작 안 하는 버그 (#144)
* fix: ios marker tap * chore: add comments --------- Co-authored-by: trevor.yang <[email protected]> Co-authored-by: MJ Studio <[email protected]>
1 parent 98fdfe0 commit 0dd7a37

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ios/Overlay/Marker/RNCNaverMapMarker.mm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ - (void)dealloc {
6666
}
6767
}
6868

69+
/**
70+
* Ensures that the touch handler is properly set up for the marker
71+
* This method checks if the touch handler exists and creates it if it doesn't
72+
* The touch handler is responsible for processing tap events on the marker
73+
*/
74+
- (void)ensureTouchHandler {
75+
if (!_inner.touchHandler) {
76+
_inner.touchHandler = [self](NMFOverlay* overlay) -> BOOL {
77+
if (self.emitter) {
78+
self.emitter->onTapOverlay({});
79+
return YES;
80+
}
81+
return NO;
82+
};
83+
}
84+
}
85+
6986
- (void)setImage:(facebook::react::RNCNaverMapMarkerImageStruct)image {
7087
_image = image;
7188
// If subview exists for custom marker, then skip image
@@ -85,6 +102,7 @@ - (void)setImage:(facebook::react::RNCNaverMapMarkerImageStruct)image {
85102
self.inner.alpha = 1;
86103
self.inner.iconImage = image;
87104
self->_imageCanceller = nil;
105+
[self ensureTouchHandler]; // Re-ensure touch handler after image is set
88106
});
89107
});
90108
}
@@ -111,6 +129,7 @@ - (void)insertReactSubview:(UIView*)subview atIndex:(NSInteger)atIndex {
111129
dispatch_async(dispatch_get_main_queue(), [self, subview]() {
112130
self.inner.alpha = 1;
113131
self.inner.iconImage = [NMFOverlayImage overlayImageWithImage:[self captureView:subview]];
132+
[self ensureTouchHandler]; // Re-ensure touch handler after custom marker image is set
114133
});
115134
}
116135

@@ -210,6 +229,9 @@ - (void)updateProps:(Props::Shared const&)props oldProps:(Props::Shared const&)o
210229
}
211230

212231
[super updateProps:props oldProps:oldProps];
232+
233+
// Ensure touch handler is properly set after marker properties are updated
234+
[self ensureTouchHandler];
213235
}
214236

215237
Class<RCTComponentViewProtocol> RNCNaverMapMarkerCls(void) {

0 commit comments

Comments
 (0)