24

次のようなデジタル値のメソッド カメラを使用します。

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

タイマーを介して現在の位置でマップを自動的に再描画する必要があります。

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

しかし、タッチで変更した場合、現在のズームを取得するにはどうすればよいですか?

4

4 に答える 4

38

OK、解決策を見つけました。現在のズームを取得します。

CGFloat currentZoom = self.MapView.camera.zoom;

そしてそれをカメラで使用します:

camera = [GMSCameraPosition cameraWithLatitude:locationManager.location.coordinate.latitude
                                     longitude:locationManager.location.coordinate.longitude
                                          zoom:currentZoom];
self.MapView.camera = camera;
于 2013-08-01T06:26:48.427 に答える
4

animateToZoom も使用できます。

self.mapView.animateToZoom(10)
于 2016-04-08T13:34:31.933 に答える