Ios 如何以编程方式在google maps xcode中移动一个点

Ios 如何以编程方式在google maps xcode中移动一个点,ios,objective-c,google-maps,google-api,Ios,Objective C,Google Maps,Google Api,我创建了一个应用程序,并使用谷歌地图api。我希望将动画移动一点(例如我的位置)到顶部。请告诉我,因为我不知道 我想当点击移动按钮我的地图移动到顶部(100px)请告诉我怎么做 这是我的代码: @implementation ViewController { double latitudes; double longitudes; CLLocationManager *locationManager; GMSMapView *mapView_; } - (void

我创建了一个应用程序,并使用谷歌地图api。我希望将动画移动一点(例如我的位置)到顶部。请告诉我,因为我不知道

我想当点击移动按钮我的地图移动到顶部(100px)请告诉我怎么做

这是我的代码:

@implementation ViewController
{
    double latitudes;
    double longitudes;
    CLLocationManager *locationManager;
    GMSMapView *mapView_;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    locationManager = [[CLLocationManager alloc] init];
    [self GetMyLocation];

    UIButton *pinButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    pinButton.frame = CGRectMake(self.view.frame.size.width-80,self.view.frame.size.height-80, 60, 60);
    [pinButton setTitle:@"Self" forState:UIControlStateNormal];
    [pinButton setBackgroundColor:[UIColor whiteColor]];
    [pinButton addTarget:self action:@selector(ShowMyLocation:)     forControlEvents:UIControlEventTouchUpInside];

    UIButton *add = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    add.frame = CGRectMake(20,self.view.frame.size.height-80, 60, 60);
    [add setTitle:@"add" forState:UIControlStateNormal];
    [add setBackgroundColor:[UIColor whiteColor]];
    [add addTarget:self action:@selector(Move:)     forControlEvents:UIControlEventTouchUpInside];

    // Create a GMSCameraPosition that tells the map to display the
    // nokte mohem ine ke baadan ye logitude & latitude default ezafe kon chon shaiad tuie ye sharaiete tokhmi ke hamid esrar dare va ye kasi mariz bood dastresie GPS ro ghat kard

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitudes longitude:longitudes zoom:14];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero  camera:camera];
    mapView_.myLocationEnabled = YES;
    [mapView_ setMapType:kGMSTypeNormal];
    self.view = mapView_;
    [mapView_ addSubview:pinButton];
    [mapView_ addSubview:add];

}
- (IBAction)Move:(id)sender{
    //move marker place
}
- (IBAction)ShowMyLocation:(id)sender{

    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(coor.latitude,coor.longitude);
    marker.title = @"I'm Here";
    marker.snippet = @"Rahnova Co.";
    marker.appearAnimation = kGMSMarkerAnimationPop;
    marker.map = mapView_;
}
- (void) GetMyLocation{
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
}
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
    NSLog(@"didFailWithError: %@", error);
    UIAlertView *errorAlert = [[UIAlertView alloc]
                               initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
    CLLocation *currentLocation = newLocation;
    if (currentLocation != nil) {
        longitudes = currentLocation.coordinate.longitude;
        latitudes = currentLocation.coordinate.latitude;
    }
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitudes longitude:longitudes zoom:14];
    [mapView_ animateToCameraPosition:camera];
}

下面是在Google内部移动的方法之一,即设置Mapview的摄像头

- (IBAction)Move:(id)sender{
  //move marker place

  CLLocationCoordinate2D moveToCoordinate = CLLocationCoordinate2DMake(0, 0);
  //0, 0 are the Coordinates that you wan to,

  GMSCameraPosition *camera =
  [GMSCameraPosition cameraWithLatitude:moveToCoordinate.latitude
                            longitude:moveToCoordinate.longitude
                                 zoom:14];
  [mapView_ animateToCameraPosition:camera];
}

你的代码是正确的,解决了我的问题。我有一个问题,我的朋友,如何在我的地图上水平地获得页面中心的坐标(纬度、经度)以及页面顶部25%的坐标???因为我想当我点击任何标记(针)我去这个坐标!!!如果我的答案是正确的,请投票并标记为答案。如果你还有其他问题,请打开一个新问题,不要在评论下提问。至于标记,您必须使用delegate方法DidTapMarker如果不需要更改缩放级别,只需转到[mapView animateToLocation:moveToCoordinate];:D