Interception affects UIView over GMSMapView

I am trying to overlay a UIView on google GMSMapView. The goal is to intercept swipes to know when the map is moving manually. (I know that I can check -mapView: willMove: but this is caused regardless of whether the card moves programmatically or as a result of a manual touch). I will programmatically reorient the map as an updated position, because Google does not do this for you, like Apple. Like any software map, I want to stop centering the current position as soon as the user manually moves the map. The only way I could capture this event (without waiting for the transition to mapkit or waiting for Google to add to the API) is to capture a swipe when it passes the view above the map.

To clarify, my question is how do I view a Google map, make it respond to napkins and allow this event to go through GMSMapView?

Both my map and interceptView are children of the main view. interceptView has a gesureRecognizer set to opaque, not hidden, and userInteractionEnabled = YES. Thus, interceptView is great for touch events. But the map below does not move. If I set interceptView.userInteractionEnabled = NO, the map is working fine.

Touch-passing by overriding strokes and calling GMSMapView touchBegan does nothing. And overriding hitTest doesn't seem to be an option, because I cannot subclass GMSMapView. Has anyone done this? I know a lot about certain events here. I want to handle a specific event in two views, one of which is the Google map layer, which I cannot change the code.

+4
source share
3 answers

mapView: willMove: receives a “bool gesture” that is true if the movement was caused by a user gesture and false if it is not. Thus, you can stop re-centering the card only if the "gesture" is right. Thus, you can be sure that the map moves manually.

+4
source

Here is the delegate method checking it

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate; 
+1
source

You can intercept the crane using GMSMapViewDelegete and implement this method:

 -(void)panoramaView:(GMSPanoramaView *)panoramaView didTap:(CGPoint)point; 

Example:

 -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; CLLocationCoordinate2D panoramaNear = {latitudine,longitudine}; GMSPanoramaView *panoView = [GMSPanoramaView panoramaWithFrame:CGRectZero nearCoordinate:panoramaNear]; [panoView setDelegate:self]; self.view = panoView; } -(void)panoramaView:(GMSPanoramaView *)panoramaView didTap:(CGPoint)point{ NSLog(@"Tap"); } 
0
source

Source: https://habr.com/ru/post/1495654/


All Articles