Google Maps SDK iOS - prevent map from changing location on zoom

后端 未结 3 1560
你的背包
你的背包 2021-01-15 09:40

I have a problem that I can\'t solve for some time.

I have a GMSMapView with imageView in front of it in the center. In result - I can drag map and always have cente

3条回答
  •  抹茶落季
    2021-01-15 10:08

    Well, after 10 days of going back to this problem, I finally solved it! The answer was pretty easy!

    Few steps here: 1. Add imageView as marker on top of the GMSMapView 2. Add UIPanGestureRecognizer to the GMSMapView (don't forget to set delegate, it is important) 3. Then use this code:

    - (void) didPan:(UIPanGestureRecognizer*) gestureRecognizer
    {
        if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
        {
            _mapView.settings.scrollGestures = true;
        }
    }
    
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
        if (gestureRecognizer.numberOfTouches > 1)
        {
            _mapView.settings.scrollGestures = false;
        }
        else
        {
            _mapView.settings.scrollGestures = true;
        }
        return true;
    }
    

提交回复
热议问题