Skip to content

Commit 080678b

Browse files
dahiri-faridrborn
authored andcommitted
zIndex doesn't work when the map moves in iOS 11 (react-native-maps#2359)
1 parent ecec7f3 commit 080678b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/ios/AirMaps/AIRMapMarker.m

+18
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ @implementation AIRMapMarker {
2828
NSInteger _zIndexBeforeOpen;
2929
}
3030

31+
- (instancetype)initWithFrame:(CGRect)frame {
32+
self = [super initWithFrame:frame];
33+
if (self) {
34+
[self.layer addObserver:self forKeyPath:@"zPosition" options:NSKeyValueObservingOptionNew context:nil];
35+
}
36+
return self;
37+
}
38+
3139
- (void)reactSetFrame:(CGRect)frame
3240
{
3341
// Make sure we use the image size when available
@@ -312,4 +320,14 @@ - (void)setZIndex:(NSInteger)zIndex
312320
self.layer.zPosition = zIndex;
313321
}
314322

323+
- (void)dealloc {
324+
[self.layer removeObserver:self forKeyPath:@"zPosition"];
325+
}
326+
327+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
328+
if ([keyPath isEqualToString:@"zPosition"]) {
329+
self.layer.zPosition = _zIndex;
330+
}
331+
}
332+
315333
@end

0 commit comments

Comments
 (0)