@@ -50,6 +50,16 @@ - (UIView *)view
5050 map.delegate = self;
5151 map.indoorDisplay .delegate = self;
5252 self.map = map;
53+ map.settings .consumesGesturesInView = NO ;
54+
55+ UIPanGestureRecognizer *drag = [[UIPanGestureRecognizer alloc ] initWithTarget: self action: @selector (handleMapDrag: )];
56+ [drag setMinimumNumberOfTouches: 1 ];
57+ [drag setMaximumNumberOfTouches: 1 ];
58+ [map addGestureRecognizer: drag];
59+
60+ UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc ] initWithTarget: self action: @selector (handleMapDrag: )];
61+ [map addGestureRecognizer: pinch];
62+
5363 return map;
5464}
5565
@@ -77,6 +87,7 @@ - (UIView *)view
7787RCT_EXPORT_VIEW_PROPERTY(onKmlReady, RCTBubblingEventBlock)
7888RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
7989RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)
90+ RCT_EXPORT_VIEW_PROPERTY(onPanDrag, RCTBubblingEventBlock)
8091RCT_EXPORT_VIEW_PROPERTY(onUserLocationChange, RCTBubblingEventBlock)
8192RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
8293RCT_EXPORT_VIEW_PROPERTY(onMarkerPress, RCTDirectEventBlock)
@@ -684,6 +695,28 @@ - (void)mapView:(GMSMapView *)mapView
684695 AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
685696 [googleMapView didTapPOIWithPlaceID: placeID name: name location: location];
686697}
698+
699+ #pragma mark Gesture Recognizer Handlers
700+
701+ - (void )handleMapDrag : (UIPanGestureRecognizer*)recognizer {
702+ AIRGoogleMap *map = (AIRGoogleMap *)recognizer.view ;
703+ if (!map.onPanDrag ) return ;
704+
705+ CGPoint touchPoint = [recognizer locationInView: map];
706+ CLLocationCoordinate2D coord = [map.projection coordinateForPoint: touchPoint];
707+ map.onPanDrag (@{
708+ @" coordinate" : @{
709+ @" latitude" : @(coord.latitude ),
710+ @" longitude" : @(coord.longitude ),
711+ },
712+ @" position" : @{
713+ @" x" : @(touchPoint.x ),
714+ @" y" : @(touchPoint.y ),
715+ },
716+ });
717+
718+ }
719+
687720@end
688721
689722#endif
0 commit comments