Google Maps SDK iOS - 防止地图在缩放时更改位置 [英] Google Maps SDK iOS - prevent map from changing location on zoom

查看:188
本文介绍了Google Maps SDK iOS - 防止地图在缩放时更改位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我有一段时间无法解决。

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

我在它前面有一个带有imageView的GMSMapView。结果 - 我可以拖动地图并始终有中心针。但是当我缩放地图时会出现问题。
在缩放时 - 地图目标的位置发生变化,我的imageView指向另一个位置。

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.

我可以检测到缩放是否发生变化,但我实际上无法强制GMSMapView执行此操作只有缩放,没有任何位置变化。

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;
    }
}

所以基本上,我想要总是居中的针脚,即使我进行变焦。
我尝试过GMSMarker - 但是在关注地图中心时遇到了性能问题。它没有立即执行,所以我决定使用imageView。

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?

推荐答案

Google用谷歌地图sdk 1.10.0解决了这个问题。

Google fixed this issue with google maps sdk 1.10.0.

解决方案是在配置GMSMapview时简单地添加这一行:

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

_mapView.settings.allowScrollGesturesDuringRotateOrZoom = NO;

这篇关于Google Maps SDK iOS - 防止地图在缩放时更改位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆