Skip to content

Commit e85ff64

Browse files
zIndex doesn't work when the map moves in iOS 11
iOS: [react-native-maps#2359](react-native-maps#2359) Fixed zIndex didn't work on map moving on iOS 11
1 parent 7b8dc04 commit e85ff64

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
@@ -27,6 +27,14 @@ @implementation AIRMapMarker {
2727
MKPinAnnotationView *_pinView;
2828
}
2929

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

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

0 commit comments

Comments
 (0)