Skip to content

Commit e19b414

Browse files
olofdrborn
authored andcommitted
Fix callouts appearing behind markers (react-native-maps#1846)
A bit ugly, but works well.
1 parent b34f7d9 commit e19b414

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/ios/AirMaps/AIRMapMarker.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
#import <React/RCTImageLoader.h>
1515
#import <React/RCTUtils.h>
1616
#import <React/UIView+React.h>
17+
NSInteger const CALLOUT_OPEN_ZINDEX_BASELINE = 999;
1718

1819
@implementation AIREmptyCalloutBackgroundView
20+
bool _calloutIsOpen = NO;
21+
NSInteger _zIndexBeforeOpen = 0;
1922
@end
2023

2124
@implementation AIRMapMarker {
@@ -137,6 +140,9 @@ - (void)fillCalloutView:(SMCalloutView *)calloutView
137140

138141
- (void)showCalloutView
139142
{
143+
_calloutIsOpen = YES;
144+
[self setZIndex:_zIndexBeforeOpen];
145+
140146
MKAnnotationView *annotationView = [self getAnnotationView];
141147

142148
[self setSelected:YES animated:NO];
@@ -222,6 +228,8 @@ - (void)_handleTap:(UITapGestureRecognizer *)recognizer {
222228

223229
- (void)hideCalloutView
224230
{
231+
_calloutIsOpen = NO;
232+
[self setZIndex:_zIndexBeforeOpen];
225233
// hide the callout view
226234
[self.map.calloutView dismissCalloutAnimated:YES];
227235

@@ -298,8 +306,9 @@ - (void)setPinColor:(UIColor *)pinColor
298306

299307
- (void)setZIndex:(NSInteger)zIndex
300308
{
301-
_zIndex = zIndex;
302-
self.layer.zPosition = _zIndex;
309+
_zIndexBeforeOpen = zIndex;
310+
_zIndex = _calloutIsOpen ? zIndex + CALLOUT_OPEN_ZINDEX_BASELINE : zIndex;
311+
self.layer.zPosition = zIndex;
303312
}
304313

305314
@end

0 commit comments

Comments
 (0)