ios - 如何从 iOS 版谷歌地图获取当前缩放级别?

标签 ios google-maps zooming cllocationmanager

我使用像这样具有数字值的方法相机:

camera = [GMSCameraPosition cameraWithLatitude:37.35 longitude:-122.0 zoom:6];

我需要通过计时器自动重绘当前位置的 map :

-(void)gmapRedraw{
    NSLog(@"gmapRedraw");
//    self.MapView.camera
    [locationManager startUpdatingLocation];
    NSLog(@"lat %f, lon %f", locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude);
    camera = [GMSCameraPosition cameraWithLatitude:locationManager.location.coordinate.latitude//37.36//-37.81319//-33.86
                                         longitude:locationManager.location.coordinate.longitude//-122.0//144.96298//151.20
                                              zoom:6];
    self.MapView.camera = camera;
}

-(void)timer{
    [NSTimer scheduledTimerWithTimeInterval:0.5
                                     target:self
                                   selector:@selector(gmapRedraw)
                                   userInfo:nil
                                    repeats:YES];
}

但是如果我通过触摸更改它,我如何才能获得当前的缩放比例?

最佳答案

好的,我找到了解决方案, 获取当前缩放:

CGFloat currentZoom = self.MapView.camera.zoom;

然后在相机中使用它:

camera = [GMSCameraPosition cameraWithLatitude:locationManager.location.coordinate.latitude
                                     longitude:locationManager.location.coordinate.longitude
                                          zoom:currentZoom];
self.MapView.camera = camera;

关于ios - 如何从 iOS 版谷歌地图获取当前缩放级别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17972670/

相关文章:

java - 在我的应用程序中出现错误 "java.lang.RuntimeException: Unable to start activity"

css - Twitter Bootstrap 和谷歌地图

android - android中的通用缩放 subview

html - 即使在缩放后也能保持网页上的图像布局?

ios - NSMutableArray addObject 似乎不起作用

html - 允许用户在 Objective C 中创建和查看 HTML 文件?

ios - 我如何在 iOS Swift4 中创建这个圆形?

android - 将 map_view 添加到我的 flutter 应用程序不成功

jquery - 有谁知道用于嵌入 pdf 对象的 jQuery 放大插件吗?

iOS 应用程序因未知原因崩溃