File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ @interface AIRMapManager() <MKMapViewDelegate>
3737
3838@end
3939
40- @implementation AIRMapManager
40+ @implementation AIRMapManager {
41+ BOOL _hasObserver;
42+ }
4143
4244RCT_EXPORT_MODULE ()
4345
@@ -704,11 +706,12 @@ - (void)mapView:(AIRMap *)mapView
704706 if (mapView.onMarkerDragEnd ) mapView.onMarkerDragEnd (event);
705707 if (marker.onDragEnd ) marker.onDragEnd (event);
706708
707- [view removeObserver: self forKeyPath: @" center" ];
709+ if (_hasObserver) [view removeObserver: self forKeyPath: @" center" ];
710+ _hasObserver = NO ;
708711 } else if (newState == MKAnnotationViewDragStateStarting) {
709712 // MapKit doesn't emit continuous drag events. To get around this, we are going to use KVO.
710713 [view addObserver: self forKeyPath: @" center" options: NSKeyValueObservingOptionNew context: &kDragCenterContext ];
711-
714+ _hasObserver = YES ;
712715 if (mapView.onMarkerDragStart ) mapView.onMarkerDragStart (event);
713716 if (marker.onDragStart ) marker.onDragStart (event);
714717 }
You can’t perform that action at this time.
0 commit comments