Search code examples
iosgoogle-maps-sdk-ios

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


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 centered pin. But problems come when I zoom the map. On zooming - position of map target changes and my imageView points to another location.

I can detect if zoom changed, but I cant actually force GMSMapView to do ONLY zoom without any location changing.

-(void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position
{
    if (mZoomLevel != mapView.camera.zoom)
    {
        mZoomLevel = mapView.camera.zoom;
    }
}

So basically, I want to have always centered pin, even if I perform zoom. I tried GMSMarker - but it has problems with performance when following map center. It doesn't do it instantly, so I decided to use imageView.

Main question: how to lock current location of the map while performing zoom?


Solution

  • Google fixed this issue with google maps sdk 1.10.0.

    The solution is to simply add this line when configuring GMSMapview:

    _mapView.settings.allowScrollGesturesDuringRotateOrZoom = NO;